Bug解决-TypeError: can‘t convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host mem

Bug:

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

解决方法:

如果想把CUDA tensor格式的数据改成numpy时,需要先将其转换成cpu float-tensor随后再转到numpy格式。将predict.data.numpy() 改为predict.data.cpu().numpy()
 

你可能感兴趣的:(~~~Bug解决~~~,numpy,bug,python)