TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy...
程序员文章站
2022-03-20 23:52:39
...
在使用Pytorch时我遇到如下错误
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
出错代码如下
out = out.detach().numpy()
如下修改就可以
out = out.detach().cpu().numpy()