Yes, thank you very much for pointing that out. However my code still gives very low accuracy and the results are hard to interpret. Here’s the output from the GCN model:
Screenshot 2020-05-11 at 10.31.331348×658 108 KB
I believe that the issue is in the way I pre-process the graph data. I have 5 graphs and for each one I convert the strings in the edge list into unique integer identifiers using a dictionary. At the end I feed the list into a DataLoader to have one large graph that includes the 5 subgraphs.
Also, I am not sure how to split the data for training and testing. Taking 80% for training and 20% for testing gives a testing accuracy of 0. In here, I split the data as follows:
data.train_mask = torch.zeros(data.num_nodes, dtype=torch.bool)
data.train_mask[:int(0.8 * data.num_nodes)] = 1 #train on the first 80% nodes
data.test_mask = torch.zeros(data.num_nodes, dtype=torch.bool) 
data.test_mask[- int(0.8 * data.num_nodes):] = 1 #test on the last 80% nodes

The pre-processing implementation for the 5 graphs is the following:
graph_list = []
label_index = 0

for graph in input_list:

    edges = np.vstack((np.array(graph["gene1"]),np.array(graph["gene2"])))
    edge_attr = np.ones(edges.shape[1])
    edge_attr = torch.as_tensor(np.expand_dims(edge_attr, 1), dtype=torch.float)

    node_features = np.unique(edges)
    number_of_nodes = node_features.shape[0]
    node_indices = []
    for i in range(number_of_nodes):
        node_indices.append(i)

    dictionary = dict(zip(node_features, node_indices))
    edge_row_1 = [dictionary[node_feat] for node_feat in edges[0]]
    edge_row_2 = [dictionary[node_feat] for node_feat in edges[1]]

    edge_ind = np.vstack((edge_row_1,edge_row_2))
    edge_index = torch.as_tensor(edge_ind, dtype=torch.long)

    x = torch.ones(number_of_nodes)
    x = torch.as_tensor(np.expand_dims(np.array(x), 1), dtype=torch.float)

    y = torch.ones(number_of_nodes)*label_index
    y = torch.as_tensor(y, dtype=torch.long)
    label_index = label_index+1

    graph_data = Data(x=x, y=y, edge_index=edge_index, edge_attr=edge_attr)
    graph_list.append(graph_data)

loader = DataLoader(graph_list, batch_size=5, shuffle=True)
batch = next(iter(loader))

Please let me know if you find anything else that is incorrect.
Thank you.