解决TypeError: expected Tensor as element 0 in argument 0, but got numpy.ndarray错误的方法

TypeError: expected Tensor as element 0 in argument 0, but got numpy.ndarray

问题描述

原因分析:

需要Tensor变量,我却给了numpy变量,所以转化一下就好啦!!

![在这里插入图片描述](https://i3.wp.com/img-blog.csdnimg.cn/161d9022dc664d3399cffe2bb8df7f30.png

我们使用torch.Tensor()方式进行转化即可

# 转换成Tensor
data0 = torch.Tensor(data0)

物联沃分享整理
物联沃-IOTWORD物联网 » 解决TypeError: expected Tensor as element 0 in argument 0, but got numpy.ndarray错误的方法

发表评论