Closed rusty1s closed 1 year ago
Would it be useful to add a Pooling
class that all pooling operators inherit from.
class Pooling(torch.nn.Module):
def forward(self, x, edge_index, *args, **kwargs):
mapping = self.select(x, edge_index, *args, **kwargs)
x = self.reduce(x, mapping)
edge_index = self.connect(mapping, edge_index, *args, **kwargs)
self.select
, reduce
and connect
would be objects defined in the child class like graclus
or TopK
.
Yes, definitely :)
Hey, first author of the paper here!
This is super, if help is still wanted (as I see on the tags) I'd be happy to participate!
Worth mentioning that there is an implementation of SRC in Spektral and a few layers implemented with it, it might be possible to translate the implementation from TF to Torch/PyG.
@danielegrattarola firstly great paper. Sorry for the late reply.
But if you are still interested we could use your help moving SAGPooling
and PANPooling
.
Just refactor topkpooling here.
benchmark of topK function
https://github.com/puririshi98/rgcn_pyg_lib_forward_bench/blob/main/topK_bench.py
topk microbench PR: https://github.com/pyg-team/pytorch_geometric/pull/7549
diff pool microbench PR: https://github.com/pyg-team/pytorch_geometric/pull/7550
https://github.com/pyg-team/pytorch_geometric/pull/7361 PR is ready to merge
🚀 The feature, motivation and pitch
The "Understanding Pooling in Graph Neural Networks" paper introduces a simple framework to unify (most) graph pooling approaches:
Currently, the pooling operators included in PyG are implemented isolated from each other, and there exists a lot of repetitive code and different interfaces, which makes their application confusing and challenging. By following the above approach, we can unify existing implementations and can accelerate new research on graph pooling. For example, we can introduce base classes for each of the aforementioned steps:
With this, e.g.,
graclus
can be moved to aSelect
operator andTopK
pooling can be moved to aConnect
operator.Relevant twitter thread: https://twitter.com/riceasphait/status/1447867635442585601
Tasks:
Select
andConnect
base classes [#6540]Pooling
base class [#6540]Add concrete
Select
andConnect
classes and update implementations of.TopKPooling
[#7308]