コード例 #1
0
				  left_word4, phonetic_input]
	all_outputs = [outputs, out1, out2, out3, out4, out5, out6]

	model = Model(input=all_inputs, output=all_outputs)
	opt = Adam()
	model.compile(optimizer=Adadelta(epsilon=1e-06), loss='categorical_crossentropy',
				  metrics=['accuracy'],
				  loss_weights=[1., 1., 1., 1., 1., 1., 1.])

	return model

sentences = pickle.load(open('./pickle-dumps/sentences_intra', 'rb'))
rootwords = pickle.load(open('./pickle-dumps/rootwords_intra', 'rb'))
features = pickle.load(open('./pickle-dumps/features_intra', 'rb'))

n_phonetics, X_train_phonetics, X_test_phonetics, X_val_phonetics, _, _, _ = returnTrainTestSets()

# we keep X_idx2word and y_idx2word the same
# X_left & X_right = X shifted to one and two positions left and right for context2
X, X_vocab_len, X_word_to_ix, X_ix_to_word, y, y_vocab_len, y_word_to_ix, y_ix_to_word, X_left1, X_left2, X_left3, X_left4, \
X_right1, X_right2, X_right3, X_right4 = load_data_for_seq2seq(sentences, rootwords, test=False, context4=True)

y1, y2, y3, y4, y5, y6, y7, y8 = load_data_for_features(features)

y1, n1, y2, n2, y3, n3, y4, n4, y5, n5, y7, n7, y8, n8, enc, labels = process_features(y1, y2, y3, y4, y5, y7, y8)

n = [n1, n2, n3, n4, n5, n7, n8]

X_max = max([len(word) for word in X])
y_max = max([len(word) for word in y])
X_max_len = max(X_max, y_max)
コード例 #2
0
    else:
        n1, n2, n3, n4, n5, n6 = n

    y1 = np_utils.to_categorical(y1, num_classes=n1)
    y2 = np_utils.to_categorical(y2, num_classes=n2)
    y3 = np_utils.to_categorical(y3, num_classes=n3)
    y4 = np_utils.to_categorical(y4, num_classes=n4)
    y5 = np_utils.to_categorical(y5, num_classes=n5)
    y6 = np_utils.to_categorical(y6, num_classes=n6)

    print("Encoders dumped ################################################")
    return (y1, n1, y2, n2, y3, n3, y4, n4, y5, n5, y6, n6, enc, labels)


path = './pickle_dumps/'
n_features, X_train, X_test, X_validation = returnTrainTestSets()
features = pickle.load(open('./pickle_dumps/test_features', 'rb'))
y1, y2, y3, y4, y5, y6 = load_data_for_features(features)
y1, n1, y2, n2, y3, n3, y4, n4, y5, n5, y6, n6, enc, labels = process_features(
    y1, y2, y3, y4, y5, y6)

pickle.dump(X_test, open(path + 'X_ga', 'wb'))
pickle.dump(y1, open(path + 'y1_ga', 'wb'))
pickle.dump(y2, open(path + 'y2_ga', 'wb'))
pickle.dump(y3, open(path + 'y3_ga', 'wb'))
pickle.dump(y4, open(path + 'y4_ga', 'wb'))
pickle.dump(y5, open(path + 'y5_ga', 'wb'))
pickle.dump(y6, open(path + 'y6_ga', 'wb'))

X = pickle.load(open(path + 'X_ga', 'rb'))
y = pickle.load(open(path + 'y1_ga', 'rb'))