Pytorch_geometric: How to use global_max_pool with one graph?

Created on 16 Jun 2020  ยท  6Comments  ยท  Source: rusty1s/pytorch_geometric

โ“ Questions & Help

I only have one graph which is have a feature matrix with n-cols and d-rows in one batch so that I don't know how should I set parameter 'batch' in this case?

global_max_pool(x, batch, size=None)
I don't know how to set the 'batch' in this case

Looking forward to your reply,thank you very mach!

All 6 comments

x.max(dim=0) or set batch via batch = x.new_zeros(x.size(0), dtype=torch.long)

x.max(dim=0) or set batch via batch = x.new_zeros(x.size(0), dtype=torch.long)

Impressive!
Thank you for such a quick respond!

I have anthor question.
In every batch,I have N graphs that means I have a (N * n) * d matrix(every graph have n nodes,but n is different between every graph).I want make the dimension of every graph form n * d become
(n * d) * 1,
final,the matrix of batch(N graphs)'s dimension become N * (n * d).

I want use torch.bincount and torch.split the matrix,but I think the method is too slow.

Do have anthor methods?

Looking forward to your reply,thank you very mach!

That's what torch_geometric.utils.to_dense_batch is doing :)

That's what torch_geometric.utils.to_dense_batch is doing :)

OK, I'll try it later.
Finall, I want to ask why the parameter 'batch' can set like you told me ? I don't know the reason.

For each node, batch holds the index of the graph the node belongs to. Since you only have a single graph, setting batch to zero assigns all nodes to the same graph (with index 0).

For each node, batch holds the index of the graph the node belongs to. Since you only have a single graph, setting batch to zero assigns all nodes to the same graph (with index 0).

I'm flattered that you're reply so quickly.
Thank you and I wish you a happy life

Was this page helpful?
0 / 5 - 0 ratings

Related issues

raeidsaqur picture raeidsaqur  ยท  4Comments

a060146251 picture a060146251  ยท  3Comments

zhangfuyang picture zhangfuyang  ยท  4Comments

Raverss picture Raverss  ยท  3Comments

Zhangzhk0819 picture Zhangzhk0819  ยท  3Comments