报错:
File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 416, in _conv_forward
self.padding, self.dilation, self.groups)
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same
在运行torch中出现这个错误。
错误内容大概就是指输入类型是CPU(torch.FloatTensor),而参数类型是GPU(torch.cuda.FloatTensor)。
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
inputs.to(device)
具体参考博客:https://blog.csdn.net/qq_27261889/article/details/86575033
我是送入网络的img即输入是cpu型的,直接加上一句代码,问题解决
img = img.cuda()