马春杰杰 Exit Reader Mode

[mcj]RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

使用pytorch的时候,想要对网络进行可视化,结果报错为:

RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

这个是使用GPU 的问题,两种修改方法:

if __name__ == '__main__':
    model = fishnet99()
    torchsummary.summary(model.cuda(), (3, 224, 224))
if __name__ == '__main__':
    model = fishnet99()
    torchsummary.summary(model, (3, 224, 224),device='cpu')

第一种就是 convert your network to cuda,第二种就是 call `torchsummary.summary` with `device=’cpu’`

本文最后更新于2019年12月25日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!