Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Tensor size mismatch in usage of captum to explain graph - Chapter 14

Aperta
#15 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
jupyter-notebook, python

Direzione di ricerca

The traceback points to the Chapter 14 notebook, the GCN.forward call in cell 87, and the custom GCNConv implementation in cell 11. Re-run the notebook and inspect the tensor shapes at the failing message-passing step. Done means the model's forward pass and loss calculation complete without the tensor-size mismatch.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I am receiving the following error:

RuntimeError: The size of tensor a (84900) must match the size of tensor b (7126) at non-singleton dimension 0

{
"name": "RuntimeError",
"message": "The size of tensor a (84900) must match the size of tensor b (7126) at non-singleton dimension 0",
"stack": "---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[87], line 21
19 model.train()
20 optimizer.zero_grad()
---> 21 log_logits = model(data.x, data.edge_index)
22 loss = F.nll_loss(log_logits, data.y)
23 loss.backward()

File ~/Desktop/Extras/Graph-Neural-Network/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py:1553, in Module._wrapped_call_impl(self, *args, **kwargs)
1551 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1552 else:
-> 1553 return self._call_impl(*args, **kwargs)

File ~/Desktop/Extras/Graph-Neural-Network/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py:1562, in Module._call_impl(self, *args, **kwargs)
1557 # If we don't have any hooks, we want to skip the rest of the logic in
1558 # this function, and just call forward.
1559 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1560 or _global_backward_pre_hooks or _global_backward_hooks
1561 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1562 return forward_call(*args, **kwargs)
1564 try:
1565 result = None

Cell In[87], line 8, in GCN.forward(self, x, edge_index)
7 def forward(self, x, edge_index):
----> 8 h = self.conv1(x, edge_index).relu()
9 h = F.dropout(h, p=0.5, training=self.training)
10 h = self.conv2(h, edge_index)

File ~/Desktop/Extras/Graph-Neural-Network/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py:1553, in Module._wrapped_call_impl(self, *args, **kwargs)
1551 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1552 else:
-> 1553 return self._call_impl(*args, **kwargs)

File ~/Desktop/Extras/Graph-Neural-Network/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py:1562, in Module._call_impl(self, *args, **kwargs)
1557 # If we don't have any hooks, we want to skip the rest of the logic in
1558 # this function, and just call forward.
1559 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1560 or _global_backward_pre_hooks or _global_backward_hooks
1561 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1562 return forward_call(*args, **kwargs)
1564 try:
1565 result = None

Cell In[11], line 20, in GCNConv.forward(self, x, edge_index)
17 deg_inv_sqrt[deg_inv_sqrt == float('inf')] = 0
18 norm = deg_inv_sqrt[row] * deg_inv_sqrt[col]
---> 20 out = self.propagate(edge_index, x=x, norm=norm)
22 return out

File ~/Desktop/Extras/Graph-Neural-Network/.venv/lib/python3.12/site-packages/torch_geometric/nn/conv/message_passing.py:523, in MessagePassing.propagate(self, edge_index, size, **kwargs)
521 if res is not None:
522 msg_kwargs = res[0] if isinstance(res, tuple) else res
--> 523 out = self.message(**msg_kwargs)
524 for hook in self._message_forward_hooks.values():
525 res = hook(self, (msg_kwargs, ), out)

Cell In[11], line 25, in GCNConv.message(self, x, norm)
24 def message(self, x, norm):
---> 25 return norm.view(-1, 1) * x

RuntimeError: The size of tensor a (84900) must match the size of tensor b (7126) at non-singleton dimension 0"
}

Lingua principale
Jupyter Notebook
Stelle
1.1k
Fork
300
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PacktPublishing/Hands-On-Graph-Neural-Networks-Using-Python

Tutte le issue di PacktPublishing/Hands-On-Graph-Neural-Networks-Using-Python

Issue simili

Altre issue su Machine Learning

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.