RuntimeError: Invalid index in scatterAdd

Bixqu: <p>Running a basic graph classification algorithm with my own data, most of the code being from <a href="https://colab.research.google.com/drive/1I8a0DfQ3fI7Njc62__mVXUlcAleUclnb?usp=sharing#scrollTo=HvhgQoO8Svw4" rel="noopener nofollow ugc">here.</a> I get the below issue in the training loop, and I don’t understand why.</p>
<p>One problem could be, my node features are not normalized, some can be 99999 and some 0.12 . Does Pytorch Geometric have a normalization method?</p>
<pre><code class="lang-auto">---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
&lt;ipython-input-9-1ad15c16fb39&gt; in &lt;module&gt;
      2 
      3 for epoch in range(1, 25):
----&gt; 4     loss = train(epoch)
      5     train_acc = test(train_loader)
      6     test_acc = test(test_loader)

&lt;ipython-input-8-6e9d94325104&gt; in train(epoch)
      6         data = data.to(device)
      7         optimizer.zero_grad()
----&gt; 8         output = model(data)
      9         loss = F.nll_loss(output, data.y.long())
     10         loss.backward()

~/anaconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    530             result = self._slow_forward(*input, **kwargs)
    531         else:
--&gt; 532             result = self.forward(*input, **kwargs)
    533         for hook in self._forward_hooks.values():
    534             hook_result = hook(self, input, result)

&lt;ipython-input-6-8fcd8f65419a&gt; in forward(self, data)
     15 
     16         # 1. Obtain node embeddings
---&gt; 17         x = self.conv1(x, edge_index)
     18         x = x.relu()
     19         x = self.conv2(x, edge_index)

~/anaconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    530             result = self._slow_forward(*input, **kwargs)
    531         else:
--&gt; 532             result = self.forward(*input, **kwargs)
    533         for hook in self._forward_hooks.values():
    534             hook_result = hook(self, input, result)

~/anaconda3/envs/py38/lib/python3.8/site-packages/torch_geometric/nn/conv/gcn_conv.py in forward(self, x, edge_index, edge_weight)
     98             self.cached_num_edges = edge_index.size(1)
     99             if self.normalize:
--&gt; 100                 edge_index, norm = self.norm(edge_index, x.size(self.node_dim),
    101                                              edge_weight, self.improved,
    102                                              x.dtype)

~/anaconda3/envs/py38/lib/python3.8/site-packages/torch_geometric/nn/conv/gcn_conv.py in norm(edge_index, num_nodes, edge_weight, improved, dtype)
     77 
     78         row, col = edge_index
---&gt; 79         deg = scatter_add(edge_weight, row, dim=0, dim_size=num_nodes)
     80         deg_inv_sqrt = deg.pow(-0.5)
     81         deg_inv_sqrt[deg_inv_sqrt == float('inf')] = 0
RuntimeError: Invalid index in scatterAdd at /opt/conda/conda-bld/pytorch_1579022027550/work/aten/src/TH/generic/THTensorEvenMoreMath.cpp:721
The above operation failed in interpreter.
Traceback (most recent call last):
  File "/home/user/anaconda3/envs/py38/lib/python3.8/site-packages/torch_scatter/scatter.py", line 22
            size[dim] = int(index.max()) + 1
        out = torch.zeros(size, dtype=src.dtype, device=src.device)
        return out.scatter_add_(dim, index, src)
               ~~~~~~~~~~~~~~~~ &lt;--- HERE
    else:
        return out.scatter_add_(dim, index, src)
</code></pre>