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)

你可能感兴趣的:(numpy,python,深度学习)