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

GINEConv assumes nn is subscriptable #5143

Closed
oiao opened this issue Aug 5, 2022 · 2 comments · Fixed by #5154
Closed

GINEConv assumes nn is subscriptable #5143

oiao opened this issue Aug 5, 2022 · 2 comments · Fixed by #5154
Labels

Comments

@oiao
Copy link
Contributor

oiao commented Aug 5, 2022

🐛 Describe the bug

There is an issue with the GINEConv class when providing the edge_dim parameter.
Line

if hasattr(self.nn[0], 'in_features'):

assumes that the passed nn is subscriptable, which is not the case when it is directly derived from nn.Module:

from torch import nn
from torch_geometric import nn as gnn

class Net(nn.Module):
    def __init__(self):
        super().__init__()
        self.lin = nn.Linear(1, 2)
    def forward(self, x):
        return self.lin(x)

gnn.GINEConv(Net(), edge_dim=3)
File torch_geometric/nn/conv/gin_conv.py:144, in GINEConv.__init__(self, nn, eps, train_eps, edge_dim, **kwargs)
    [142]     self.register_buffer('eps', torch.Tensor([eps]))
    [143] if edge_dim is not None:
--> [144]     if hasattr(self.nn[0], 'in_features'):
    [145]         in_channels = self.nn[0].in_features
    [146]     else:

TypeError: 'Net' object is not subscriptable

Environment

  • PyG version: 2.0.4
  • PyTorch version: 1.12
  • OS: Ubuntu
  • Python version: 3.8
  • CUDA/cuDNN version: 11.3
  • How you installed PyTorch and PyG (conda, pip, source): pip
@oiao oiao added the bug label Aug 5, 2022
@rusty1s
Copy link
Member

rusty1s commented Aug 6, 2022

Thanks for reporting. Will look into it.

@Padarn
Copy link
Contributor

Padarn commented Aug 7, 2022

I had some spare time, so raised a PR to address this.

@rusty1s rusty1s linked a pull request Aug 7, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants