Pytorch出现RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor)
生活随笔
收集整理的這篇文章主要介紹了
Pytorch出现RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這個問題的主要原因是輸入的數據類型與網絡參數的類型不符。
Input type為torch.cuda.FloatTensor(GPU數據類型), weight type(即net.parameters)為torch.FloatTensor(CPU數據類型)
有以下兩種方法
方法一
device = torch.device('cuda:0') net.to(device)方法二:
net = net.cuda()總結
以上是生活随笔為你收集整理的Pytorch出现RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: k8s pod内部容器_第三章 pod:
- 下一篇: 【Pytorch神经网络理论篇】 03