Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an ipython notebook tutorial to introduce the new torch_geometric.nn.aggr package #4920

Closed
lightaime opened this issue Jul 5, 2022 · 3 comments · Fixed by #4927
Closed

Comments

@lightaime
Copy link
Contributor

lightaime commented Jul 5, 2022

🚀 The feature, motivation and pitch

We would like to add an ipython notebook to demonstrate the new flexible interface of the new torch_geometric.nn.aggr package with MessagePassing. In the new integration, the following functionality is applicable:

# Original interface with string type as aggregation argument
class MyConv(MessagePassing):
    def __init__(self):
        super().__init__(aggr="mean")

# Use a single aggregation module as aggregation argument
class MyConv(MessagePassing):
    def __init__(self):
        super().__init__(aggr=MeanAggregation())

# Use a list of aggregation strings as aggregation argument
class MyConv(MessagePassing):
    def __init__(self):
        super().__init__(aggr=['mean', 'max', 'sum', 'std', 'var'])

# Use a list of aggregation modules as aggregation argument
class MyConv(MessagePassing):
    def __init__(self):
        super().__init__(aggr=[
          MeanAggregation(),
          MaxAggregation(),
          SumAggregation(),
          StdAggregation(),
          VarAggregation(),
          ])

# Use a list of mixed modules and strings as aggregation argument
class MyConv(MessagePassing):
    def __init__(self):
        super().__init__(aggr=[
          'mean',
          MaxAggregation(),
          'sum',
          StdAggregation(),
          'var',
          ])

# Define multiple learnable aggregations with keyword arguments
class MyConv(MessagePassing):
    def __init__(self):
        super().__init__(aggr=['softmax', 'softmax', 'softmax'],
        aggr_kwargs = dict(aggrs_kwargs=[
                            dict(t=0.1, learn=True),
                            dict(t=1, learn=True),
                            dict(t=10, learn=True)]))

# Define multiple aggregations with `MultiAggregation` module
class MyConv(MessagePassing):
    def __init__(self):
        super().__init__(aggr=MultiAggregation([
          SoftmaxAggregation(t=0.1, learn=True),
          SoftmaxAggregation(t=1, learn=True),
          SoftmaxAggregation(t=10, learn=True)]))
@lightaime lightaime changed the title Add an iPython notebook tutorial to introduce the new torch_geometric.nn.aggr package Add an ipython notebook tutorial to introduce the new torch_geometric.nn.aggr package Jul 5, 2022
@rusty1s
Copy link
Member

rusty1s commented Jul 6, 2022

Thank you @lightaime. I will go over the notebook. In the meantime, can you add a link to it to our documentation Colab page?

@lightaime
Copy link
Contributor Author

Sure, added a pull request here: #4927.

@rusty1s
Copy link
Member

rusty1s commented Jul 7, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants