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)

posted @ 2021-07-18 10:04  achived  阅读(2558)  评论(0编辑  收藏  举报