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


报错内容为:输入的是cuda类型的数据,但是使用的权重类型不是,他们的类型应当一致。

解决方法

将你的网络模型改为cuda类型即可(在使用模型之前)。

如                      model_class =  yourModelName()  

    old version:   model_class(x)

   new version:  model_class.cuda()

          model_class(x)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM