I am working on materials property prediction using GNNs with torch_geometric.
Each data in my dataset has different number of feature vectors x
, edge_index vectors edge_index
. What I'm doing is to pad all the feature vectors and edge_index features, respectively, to the length of the element with maximum length. For example, this is what I do for the edge_index vector:
In: edge_index = train_set[14].edge_index
edge_index
Out: tensor([[1, 0, 2, 0, 2, 1],
[0, 1, 0, 2, 1, 2]])
In: fill_zeros(edge_index, 15, 1)
Out: tensor([[1, 0, 2, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
i.e., I defined a function called fill_zeros
to fill in the dummy variables 0's till the tensor being acted on has length $15$.
However, this incurs many problems when feeding my data into GNN models when doing the message passing. More specifically, when running propagate()
. I wonder what're the standard ways of padding data for GNN models to avoid such problems?