报错截图: TypeError: can’t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first. 报错原因 numpy是cpu only的,所以需要先用cpu()转换到CPU 解决方法 加上cpu() 原代码: 修改后的代码: