torch_geometric实现论文《The Emerging Field of Signal Processing on Graphs》中的算法,有问题请求指导(已解决)

本文分享了使用Pytorch和PytorchGeometric构建图神经网络的实战经验,针对实验过程中遇到的错误进行了详细分析,并提供了修改后的代码实现,强调了自定义tensor移至GPU的重要性。

最近,尝试使用Pytorch和Pytorch Geometric(PyG),构建图神经网络架构,根据论文《The Emerging Field of Signal Processing on Graphs》中的算法,用PyG重现实验,出现错误及程序源代码如下,请求指导,谢谢!(已解决)

RuntimeError                              Traceback (most recent call last)
<ipython-input-14-14adeb5271eb> in <module>
      2 best_val_acc = test_acc = 0
      3 for epoch in range(1, 201):
----> 4     train()
      5     train_acc, val_acc, tmp_test_acc = test()
      6     if val_acc > best_val_acc:

<ipython-input-12-f9f6ce4bd81a> in train()
      5     optimizer.zero_grad()
      6     # 将误差反向传播
----> 7     F.nll_loss(model()[data.train_mask], data.y[data.train_mask]).backward()
      8     # 更新参数
      9     optimizer.step()

D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
    539             result = self._slow_forward(*input, **kwargs)
    540         else:
--> 541             result = self.forward(*input, **kwargs)
    542         for hook in self._forward_hooks.values():
    543             hook_result = hook(self, input, result)

<ipython-input-10-a5f12f83ff5c> in forward(self)
     10         x, edge_index = data.x, data.edge_index
     11 
---> 12         x = self.conv1(x, edge_index)
     13         x = F.relu(x)
     14         x = F.dropout(x, training=self.training)

D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
    539             result = self._slow_forward(*input, **kwargs)
    540         else:
--> 541             result = self.forward(*input, **kwargs)
    542         for hook in self._forward_hooks.values():
    543             hook_result = hook(self, input, result)

<ipython-input-9-e745cda6afb6> in forward(self, x, edge_index)
     33 
     34         # Step 3-5: Start propagating messages.
---> 35         return self.propagate(edge_index, size=(x.size(0), x.size(0)), x=x)
     36 
     37     def message(self, x_j, edge_index, size):

D:\Anaconda3\lib\site-packages\torch_geom
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值