【笔记】plt.plot 打印列表报错:列表元素应该是使用cpu设备并且不参与梯度计算才可以转化为numpy进行绘图

1. 列表元素是gpu时报错:

TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

2.列表元素是cpu时仍然报错:

RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.

猜你喜欢

转载自blog.csdn.net/nyist_yangguang/article/details/124177037