How to convert between dense batches and sparse batches efficiently? #2606
Unanswered
wzhang2022
asked this question in
Q&A
Replies: 1 comment
-
There exists the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In
torch_geometric.utils
, there's theto_dense_batch
function which allows me to get node features of a batch of graphs as a single tensor of shape(batch_size, n_max, d)
along with a boolean mask of shape(batch_size, n_max)
, wheren_max
is the size of the largest node. Is there an equivalent function for edge indices, which would output a tensor(batch_size, e_max, 2)
along with a mask(batch_size, e_max)
? Also, is there a function that would reverse this (i.e. given a dense batch tensor of nodes/edges, output a batch stored as a single graph ofbatch_size
disconnected components the way that PyTorch normally treats batches)?Additionally, I want to be able to differentiate through this operation as well.
Beta Was this translation helpful? Give feedback.
All reactions