Skip to content
Discussion options

You must be logged in to vote

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 the cluster, and then the value you want to pool:

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_po…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YunYunY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants