调试报错
RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same
截图

说明
在调试运行导师给的程序Residual Net的GunPoint程序时,出现报错,调试结果为输入与网络不符。
原因
- 输入的数据类型与网络参数的类型不符
- Input type为torch.cuda.FloatTensor(GPU数据类型), weight
type(即net.parameters)为torch.FloatTensor(CPU数据类型)
解决方案
net = mdl.ResNet()
改为↓
net = mdl.ResNet().cuda()
环境
vscode+pytorch环境(python3.6.10)
在vscode+pytorch(python3.6.10)环境下调试导师给的Residual Net的GunPoint程序时,出现RuntimeError报错,原因是输入的数据类型(GPU数据类型)与网络参数的类型(CPU数据类型)不符,解决方案是将net = mdl.ResNet()改为net = mdl.ResNet().cuda()。
215

被折叠的 条评论
为什么被折叠?



