can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first

原因分析:数据在cuda() ,需要将 float 型的tensor转化为numpy ,只能在cpu上进行

更改前的样子:

labels_=labels_.numpy().tolist()

 更改后的样子哦

labels_=labels_.cpu().numpy().tolist()
发布了234 篇原创文章 · 获赞 61 · 访问量 12万+

猜你喜欢

转载自blog.csdn.net/weixin_42528089/article/details/104926787