Pytorch_geometric: [GCNConv] `scatter_add()` parameter number unmatched error

Created on 13 Apr 2020  ·  2Comments  ·  Source: rusty1s/pytorch_geometric

🐛 Bug

Hi, I just use PyG 1.3.0 and found this problem, I don't know why? So could you please check it? Since the internal code of GCNConv has changed completely as I could not understand somehow...

Traceback (most recent call last):
  File "/home/samuel/gaodaiheng/3DFace/pyG/gcn_example.py", line 41, in <module>
    x = conv(x, edge_index)
    .... 
  File "/home/samuel/anaconda3/envs/pytorch3d/lib/python3.6/site-packages/torch_geometric/utils/scatter.py", line 28, in scatter_
    out = op(src, index, 0, None, dim_size, fill_value)
RuntimeError: scatter_add() expected at most 5 argument(s) but received 6 argument(s). Declaration: scatter_add(Tensor src, Tensor index, int dim=-1, Tensor? out=None, int? dim_size=None) -> (Tensor)

Minic code to Reproduce

import torch
from torch_geometric.data import Data
from torch_geometric.nn import GCNConv

torch.manual_seed(0)

# define edges
edge_index = torch.tensor([[0, 1, 1, 2],
                           [1, 0, 2, 1]], dtype=torch.long)

# define node feature
x = torch.tensor([[-1,2], [0,4], [1,5]], dtype=torch.float)

# create GCNConv(2, 1)
conv = GCNConv(2, 1)

# forward
x = conv(x, edge_index)
print(x)

When I first run this code, it reminds me to change inv_mask = 1 - mask to inv_mask = ~mask in loop.py/add_remaining_self_loops, after I fixed it, the above problem of scatter_add() rises...

Expected behavior

tensor([[2.0028],
            [3.1795],
            [3.1302]], grad_fn=<AddBackward0>)

Environment

  • OS: Ubuntu18.04
  • Python version: 3.6.8
  • PyTorch version: 1.4.0
  • CUDA/cuDNN version: 10.0
  • GCC version: 7.4.0
  • Any other relevant information:

Additional context

I am wondering if this problem raises as I install pytorch-geometric through conda? Thank you very much!

Most helpful comment

Please update to the latest torch-geometric==1.4.3.

All 2 comments

Please update to the latest torch-geometric==1.4.3.

Please update to the latest torch-geometric==1.4.3.

Thx, bro

Was this page helpful?
0 / 5 - 0 ratings