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

模型输入的数据类型要与模型参数的数据类型一致。
torch.cuda.HalfTensor:对应

 np.array(x, dtype = 'float32')

torch.cuda.FloatTensor:对应

 np.array(x, dtype = 'float16')


 

参考链接:
https://stackoverflow.com/questions/65029217/runtimeerror-input-type-torch-cuda-floattensor-and-weight-type-torch-cuda-ha

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐