Created
June 7, 2019 15:03
-
-
Save sbalnojan/d7514394aa41494eea969f2995a507c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
graph_conv_filters = np.concatenate([A_norm, np.matmul(A_norm, A_norm)], axis=0) | |
graph_conv_filters = K.constant(graph_conv_filters) | |
num_filters = 2 | |
model = Sequential() | |
model.add(GraphCNN(Y.shape[1], num_filters, graph_conv_filters, input_shape=(X.shape[1],), activation='elu', | |
kernel_regularizer=l2(5e-4))) | |
model.add(Activation('softmax')) | |
model.compile(loss='categorical_crossentropy', optimizer=Adam(lr=0.01), metrics=['acc']) | |
model.summary() | |
nb_epochs = 100 | |
for epoch in range(nb_epochs): | |
model.fit(X, y_train, sample_weight=train_mask, batch_size=A.shape[0], epochs=1, shuffle=False, verbose=0) | |
Y_pred = model.predict(X, batch_size=A.shape[0]) | |
_, train_acc = utils.evaluate_preds(Y_pred, [y_train], [idx_train]) | |
_, test_acc = utils.evaluate_preds(Y_pred, [y_test], [idx_test]) | |
print("Epoch: {:04d}".format(epoch), "train_acc= {:.4f}".format(train_acc[0]), "test_acc= {:.4f}".format(test_acc[0])) | |
# | |
# Epoch: 0017 train_acc= 1.0000 test_acc= 0.7930 | |
# Epoch: 0099 train_acc= 1.0000 test_acc= 0.8030 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment