Python 编写神经网络推理测试代码

Python 编写神经网络推理测试代码,python,neural-network,pytorch,inference,Python,Neural Network,Pytorch,Inference,我正在努力为你做准备 但是,我遇到了以下错误。有人能评论一下如何绕过这个cpu/gpu后端错误吗 [kevin@linux 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 63, in

我正在努力为你做准备

但是,我遇到了以下错误。有人能评论一下如何绕过这个cpu/gpu后端错误吗

[kevin@linux 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 63, in
prediction = predict_image(imagepath)
File “predict.py”, line 47, in predict_image
output = model(input)
File “/usr/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 477, in call
result = self.forward(*input, **kwargs)
File “/home/kevin/Documents/Grive/Personal/Coursera/Machine_Learning/pruning/Pruning-CNN/SqueezeNet-Pruning/finetune.py”, line 39, in forward
x = self.features(x)
File “/usr/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 477, in call
result = self.forward(*input, **kwargs)
File “/usr/lib/python3.7/site-packages/torch/nn/modules/container.py”, line 92, in forward
input = module(input)
File “/usr/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 477, in call
result = self.forward(*input, **kwargs)
File “/usr/lib/python3.7/site-packages/torch/nn/modules/conv.py”, line 313, in forward
self.padding, self.dilation, self.groups)
RuntimeError: Expected object of backend CPU but got backend CUDA for argument #2 ‘weight’
[kevin@linux SqueezeNet-Pruning]$

我认为这可能与GPU的使用有关。我认为该程序可能与GPU的正确配置一起工作。或者您可以删除行