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

报错:

RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same or input should be a MKLDNN tensor and weight is a dense tensor

解释:pytorch跑网络模型,输入的类型为CPU数据类型,但是权重类型为GPU类型
解决:把输入类型转换为GPU类型

device = torch.device('cuda:0')
inputs = inputs.to(device)

你可能感兴趣的:(错误汇总,深度学习,pytorch,python)