def test_predict_proba(self): pickle_fname = 'abp_CV_fold_1_tlXlY_trn.pkl' gcn_graph = GCNDataset.load_transkribus_pickle(pickle_fname) gcn_graph_train = [gcn_graph[8], gcn_graph[18], gcn_graph[29]] node_dim = gcn_graph[0].X.shape[1] edge_dim = gcn_graph[0].E.shape[1] - 2.0 nb_class = gcn_graph[0].Y.shape[1] gcn_model = GraphAttNet(node_dim, nb_class, num_layers=1, learning_rate=0.01, node_indim=-1, nb_attention=3) gcn_model.dropout_rate_node = 0.2 gcn_model.dropout_rate_attention = 0.2 gcn_model.create_model() with tf.Session() as session: session.run([gcn_model.init]) # Get the Test Prediction gcn_model.train_lG(session, gcn_graph) g_proba = gcn_model.prediction_prob(session, gcn_graph_train[1]) print(g_proba.shape) print(type(g_proba)) print(gcn_graph_train[1].X.shape) self.assertTrue(g_proba.shape == (gcn_graph_train[1].X.shape[0], 5))
def test_graphattnet_train_dropout(self): pickle_fname = 'abp_CV_fold_1_tlXlY_trn.pkl' gcn_graph = GCNDataset.load_transkribus_pickle(pickle_fname) gcn_graph_train = [gcn_graph[8], gcn_graph[18], gcn_graph[29]] node_dim = gcn_graph[0].X.shape[1] edge_dim = gcn_graph[0].E.shape[1] - 2.0 nb_class = gcn_graph[0].Y.shape[1] gcn_model = GraphAttNet(node_dim, nb_class, num_layers=1, learning_rate=0.01, node_indim=-1, nb_attention=3) gcn_model.dropout_rate_node = 0.2 gcn_model.dropout_rate_attention = 0.2 gcn_model.create_model() with tf.Session() as session: session.run([gcn_model.init]) # Get the Test Prediction g_acc, node_acc = gcn_model.test_lG(session, gcn_graph_train) print('Mean Accuracy', g_acc, node_acc) gcn_model.train_lG(session, gcn_graph) g_acc, node_acc = gcn_model.test_lG(session, gcn_graph_train) print('Mean Accuracy', g_acc, node_acc)