【发布时间】:2019-05-22 21:04:09
【问题描述】:
我正在使用modified predict.py 来测试pruned SqueezeNet Model
[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()的情况下,我应该如何修改代码以摆脱此错误?
【问题讨论】:
标签: numpy neural-network pytorch pruning