Tensor size mismatch in usage of captum to explain graph - Chapter 14
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- jupyter-notebook, python
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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"
}
- 主要语言
- Jupyter Notebook
- 星标
- 1.1k
- 派生
- 300
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PacktPublishing/Hands-On-Graph-Neural-Networks-Using-Python 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 55/100
PacktPublishing/Hands-On-Graph-Neural-Networks-Using-Python#22 ·
-
难度 3/5 1-2 天 新手友好度 30/100
PacktPublishing/Hands-On-Graph-Neural-Networks-Using-Python#20 ·
-
难度 2/5 1-3 小时 新手友好度 35/100
PacktPublishing/Hands-On-Graph-Neural-Networks-Using-Python#19 · 2 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 35/100
PacktPublishing/Hands-On-Graph-Neural-Networks-Using-Python#18 ·
-
HAN -未关闭
难度 2/5 1-3 小时 新手友好度 45/100
PacktPublishing/Hands-On-Graph-Neural-Networks-Using-Python#16 · 1 条评论 ·
查看 PacktPublishing/Hands-On-Graph-Neural-Networks-Using-Python 的全部 Issue
相似的 Issue
-
multi_class that used on tutorial has been deprecated on sklearn 1.5 version可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1-3 小时 新手友好度 72/100
microsoft/ML-For-Beginners#1059 · 1 条评论 ·
-
predict_file with crop_model duplicates predictions once per image可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
weecology/DeepForest#1445 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
NVIDIA/physicsnemo#2214 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
microsoft/onnxscript#3143 ·
维护者通常 3 天内回复
-
LLM.save() discards the model's active prompt style可能已有人在做 @remote-controlled-man 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
Lightning-AI/litgpt#2378 ·
维护者通常 23 天内回复