I want to train my Graph NN via mini-batch paradigm. I use torch_geometric lib.
I have following tensor:
edge_index_train = tensor([[ 0, 1, 1, ..., 319032, 285656, 471076], [941104, 941105, 941106, ..., 941282, 941379, 941498]])
and data:
data_train = Data(user_nodes=user_nodes_train, item_nodes=item_nodes_train, edge_index=edge_index_train)
Then I create NeighborLoader:
input_nodes_train = torch.arange(0, num_users_train).long() train_loader = NeighborLoader(data_train, input_nodes=input_nodes_train, num_neighbors=sizes, batch_size=batch_size, subgraph_type='induced', shuffle=True)
where input_nodes_train contains indices of vertices that must be taken as a basis when generating neighborhoods (these are the vertices that are contained in edge_index_train[0]).
But when I try to iterate through train_loader, using:
for batch in train_loader: print(batch) break
I get the batch with empty batch.edge_index:
Data(edge_index=[2, 0], user_nodes=[32], item_nodes=[6415], n_id=[32], e_id=[0], input_id=[32], batch_size=32)
What could be the problem and how to fix it?
I tried to revert graph's edges, i.e. swap data.edge_index[0] and data.edge_index[1].