Pytorch Geometric Temporal Graph ConvLSTM

Ditsuhi: <p>Hello everyone,</p>
<p>I recently started to use Graph NN, and still it is challenging for me.</p>
<p>I was following this tutorial: <a href="https://www.youtube.com/watch?v=Rws9mf1aWUs" rel="noopener nofollow ugc">https://www.youtube.com/watch?v=Rws9mf1aWUs</a> . Instead Attention Temporal Graph Convolutional, I want to use Graph ConvLSTM,  however, I have trouble constructing it. I will appreciate a lot, if someone can help. Below is the code:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/e/5e08527936d14bc7a43642d03bf95eea0ee2127e.png" data-download-href="https://discuss.pytorch.org/uploads/default/5e08527936d14bc7a43642d03bf95eea0ee2127e" title="Screenshot 2022-03-27 at 18.23.54"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/5/e/5e08527936d14bc7a43642d03bf95eea0ee2127e_2_571x500.png" alt="Screenshot 2022-03-27 at 18.23.54" data-base62-sha1="dpQIamfxjWUl3SpaiW88l6pxkpo" width="571" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/5/e/5e08527936d14bc7a43642d03bf95eea0ee2127e_2_571x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/5/e/5e08527936d14bc7a43642d03bf95eea0ee2127e_2_856x750.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/5/e/5e08527936d14bc7a43642d03bf95eea0ee2127e_2_1142x1000.png 2x" data-dominant-color="EFEFF0"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot 2022-03-27 at 18.23.54</span><span class="informations">1422×1244 181 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/b/ebd8d4cc9d43d44d912e0671161995c0f167a84d.png" data-download-href="https://discuss.pytorch.org/uploads/default/ebd8d4cc9d43d44d912e0671161995c0f167a84d" title="Screenshot 2022-03-27 at 18.18.14"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/b/ebd8d4cc9d43d44d912e0671161995c0f167a84d_2_690x481.png" alt="Screenshot 2022-03-27 at 18.18.14" data-base62-sha1="xEoLocp4i741hncIZYkC2gf854h" width="690" height="481" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/b/ebd8d4cc9d43d44d912e0671161995c0f167a84d_2_690x481.png, https://discuss.pytorch.org/uploads/default/optimized/3X/e/b/ebd8d4cc9d43d44d912e0671161995c0f167a84d_2_1035x721.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/e/b/ebd8d4cc9d43d44d912e0671161995c0f167a84d_2_1380x962.png 2x" data-dominant-color="F0F0EF"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot 2022-03-27 at 18.18.14</span><span class="informations">1576×1100 135 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/b/9/b9bb1f7ddb01b092d238609f7a9c928c35b50f18.png" data-download-href="https://discuss.pytorch.org/uploads/default/b9bb1f7ddb01b092d238609f7a9c928c35b50f18" title="Screenshot 2022-03-27 at 18.18.21"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/b/9/b9bb1f7ddb01b092d238609f7a9c928c35b50f18_2_690x267.png" alt="Screenshot 2022-03-27 at 18.18.21" data-base62-sha1="qv3eXkHI4Ugw1r9LW4SwtxQfxI4" width="690" height="267" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/b/9/b9bb1f7ddb01b092d238609f7a9c928c35b50f18_2_690x267.png, https://discuss.pytorch.org/uploads/default/optimized/3X/b/9/b9bb1f7ddb01b092d238609f7a9c928c35b50f18_2_1035x400.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/b/9/b9bb1f7ddb01b092d238609f7a9c928c35b50f18_2_1380x534.png 2x" data-dominant-color="F6F6F8"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot 2022-03-27 at 18.18.21</span><span class="informations">2122×824 136 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Thanks.<br>
Best regards,<br>
Ditsuhi</p>

ptrblck: <p>Based on the error message it seems your input contains invalid indices which are used in the <code>scatter_add_</code> operation.<br>
In particular indices in <code>[0, 19]</code> are expected while your input contains at least an index of <code>20</code>.</p>
<p>PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier.</p>

Ditsuhi: <p>Thank you so much.<br>
I was following this notebook in order to create the dataset: <a href="https://colab.research.google.com/drive/132hNQ0voOtTVk3I4scbD3lgmPTQub0KR?usp=sharing" class="inline-onebox" rel="noopener nofollow ugc">Google Colab</a>.</p>
<p>In my example I have this result: Data(x=[24, 20, 6], edge_index=[2, 552], edge_attr=[552], y=[24, 6]), where 24 is number of nodes, 20 is node features, 6 is timesteps.</p>
<p>Do I need to create my dataset different way for Graph ConvLSTM?</p>

Biagio_Principe: <p>Hi same problem here:</p>
<pre><code class="lang-auto"># Error Here ! =&gt; Number of nodes
gcn = GCN(in_channels=1, hidden_channels=32, out_channels=12, num_layers=1)
for time, snapshot in enumerate(train_loader):
    if time == 1:
        break
    print(f"{snapshot=}")
    import pdb; pdb.set_trace()
    gcn(snapshot.x, edge_index=snapshot.edge_index, edge_weight=snapshot.edge_weight, edge_attr=snapshot.edge_attr)

&gt;&gt;&gt; snapshot=Data(x=[32, 1, 24], edge_index=[2, 116], edge_attr=[116], y=[32, 24])

&gt;&gt;&gt; RuntimeError: index 2 is out of bounds for dimension 0 with size 1
</code></pre>
<p>The problem seems to come from the GCN part:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/4/34eac918e94f27dcc693bdb47cdb15541fbf4d72.png" data-download-href="https://discuss.pytorch.org/uploads/default/34eac918e94f27dcc693bdb47cdb15541fbf4d72" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/3/4/34eac918e94f27dcc693bdb47cdb15541fbf4d72.png" alt="image" data-base62-sha1="7y7QXn4zIYhXACv9JWksAtGtSam" width="591" height="500" data-dominant-color="26282A"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">801×677 33.4 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Can someone help? Grazie <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>