-
I'm playing around with a dataset for graph classification where the graph is the same for all training instances, but the features are different from one training instance to the next. I'm trying to find a way to make Pytorch Geometric work for this case without duplicating the edges for each training instance so as to be as memory efficient as possible. How might I approach doing this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
@mdanb, Iam trying to understand why you need to duplicate edges for each training instance, you could pass the same edge_index variable every time you call forward. Maybe you could paste a short snippet of your training code. Also check out layers like GCNConv, if |
Beta Was this translation helpful? Give feedback.
-
Some GNN operators have static graph support built-in, e.g., in x = [batch_size, num_nodes, num_features]
edge_index = [2, num_edges] # Edge-connectivity of a single graph
out = GCNConv(...)(x, edge_index)
# out will have shape [batch_size, num_nodes, num_new_features] To be even more memory-efficient, I suggest you to use the |
Beta Was this translation helpful? Give feedback.
Some GNN operators have static graph support built-in, e.g., in
GCNConv
you can do:To be even more memory-efficient, I suggest you to use the
SparseTensor
class for encoding edges, see here.