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://img-blog.csdnimg.cn/161d9022dc664d3399cffe2bb8df7f30.png

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

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

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年11月30日
下一篇 2023年11月30日

相关推荐