
Error_pytorch
风会记得一朵花的香:)
这个作者很懒,什么都没留下…
展开
-
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the
pytorch报错:RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same 源代码: # 加载模型 model = torch.load("test_0.pth") model.eval() with torch.no_grad(): output = model(img) 原因: GPU上面训练的模型在cpu上进行加载和使用 修改: 加载模型时原创 2022-01-29 10:13:21 · 1589 阅读 · 0 评论 -
AssertionError: size of input tensor and input format are different.
在写代码的时候出现以下错误:AssertionError: size of input tensor and input format are different. tensor shape: (64, 3, 32, 32), input_format: CHW #原因:tensor的维度是(64,3,32,32)而要求的输入格式是CHW,两者不匹配所以报错。 解决办法:用add_images方法替换add_image方法即可。 ...转载 2022-01-24 17:30:29 · 2169 阅读 · 0 评论