五、RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor)

报错如下:

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

Input type (torch.cuda.FloatTensor) :代表输入在 GPU 上
weight type (torch.FloatTensor):代表模型在 CPU 上
需要将模型转到 GPU 上,即:model.cuda()

猜你喜欢

转载自blog.csdn.net/panchang199266/article/details/128153179