Custom Aggregation function #7752
-
Beta Was this translation helpful? Give feedback.
Answered by
akihironitta
Jul 16, 2023
Replies: 2 comments
-
Hi @rajajisai! I recently tried the same thing in my PR #7459. I hope this helps :) import torch
from torch_geometric.utils import index_sort, to_dense_batch
src_feat = torch.tensor(
[
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5],
[6, 6, 6],
]
)
dst_indices = torch.tensor([1, 2, 5, 5, 5, 1], dtype=torch.long)
# to_dense_batch assumes that the indices are sorted
_, indices = index_sort(dst_indices)
result, _ = to_dense_batch(src_feat[indices], dst_indices[indices])
print(result)
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rajajisai
-
@akihironitta you are a savior!! I am extremely thankful for the quick response. My only regret is not posting the query sooner :) |
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
Hi @rajajisai! I recently tried the same thing in my PR #7459. I hope this helps :)