报错:
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same
分析原因:
cpu和cdua 使用的不一致,比如说你的模型和输入,一个在cpu上,一个在cuda上,导致这样的错误。
解决方法:
net = Model(cfg).to(device)
net.load_state_dict(torch.load(w2))
中的device,看输入的img是在cpu上还是cuda上,调整一下,要么是cpu要么是cuda
pytorch RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor)
最新推荐文章于 2024-04-28 14:51:33 发布