-
Hi, I was trying to figure out how to get NxKxC from edge_index produced by knn_graph. Probably In other words, is there a way to have a 'dense' representation of the K neighbors? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yes, reshaping only works in case of more than One way to fix this is to utilize row, col = knn(...)
row = torch.arange(num_nodes).view(-1, 1).repeat(1, k).view(-1)
col, mask = to_dense_batch(col, batch=row, fill_value=-1) Let me know if this works for you! |
Beta Was this translation helpful? Give feedback.
Yes, reshaping only works in case of more than
k
nodes in the graph.One way to fix this is to utilize
to_dense_batch
(untested):Let me know if this works for you!