-
Hi, Background: I am implementing spatial average pooling after eq. 5 of paper
If I do
I got Thank you very much for your time. I found one related discussion here. Regarding the answer for the issue, shouldn't we use the following method to create clusters for different batch?
This will print
If creating the new_cluster with this we will get
Every node would be assigned to a different cluster. I applied
But the error shows:
Is this a bug or I misunderstood something? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You are right that you need to modify import torch
from torch_geometric.nn import avg_pool_x
batch = torch.tensor([
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4
])
x = torch.randn(batch.size(0), 128)
cluster = torch.tensor([
0, 1, 1, 2, 2, 3, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 1,
1, 2, 2, 3, 3, 0, 1, 1, 2, 3, 0, 0, 1, 1, 2, 2, 3
])
cluster_max = cluster.max().item() + 1
new_cluster = batch * cluster_max + cluster
out, _ = avg_pool_x(new_cluster, x, batch) |
Beta Was this translation helpful? Give feedback.
You are right that you need to modify
cluster
to account for different examples in a batch. For_avg_pool_x
, you need to first pass in thecluster
, and then the value you want to pool: