expected scalar type Double but found Float

tensor的类型默认了,这个时候如果使用torch.tensor转numpy,只需要加一个指定dtype就可以

c = torch.tensor(c,dtype=torch.float32)

如果是torch.ones也是用dtype,参考源文件里的写法


版权声明:本文为qq_42530436原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。