我正在使用修改后的 predict.py来测试修剪后的 SqueezeNet 模型
[phung@archlinux SqueezeNet-Pruning]$ python predict.py --image 3_100.jpg --model model_prunned --num_class 2
prediction in progress
Traceback (most recent call last):
File “predict.py”, line 66, in
prediction = predict_image(imagepath)
File “predict.py”, line 52, in predict_image
index = output.data.numpy().argmax()
TypeError: can’t convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
[phung@archlinux SqueezeNet-Pruning]$
我知道 numpy 还不支持 GPU。
在不调用张量复制数据操作的情况下,我应该如何修改代码以摆脱此错误tensor.cpu()
?