@Amrit_Das Did you encounter the following cpu/gpu backend error ? and how to go around it ?

  
      github.com
  
  
    amrit-das/Custom-Model-Training-PyTorch/blob/master/predict.py#L43

    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ])
image_tensor = transformation(image).float()
image_tensor = image_tensor.unsqueeze_(0)


if torch.cuda.is_available():
    image_tensor.cuda()


input = Variable(image_tensor)
output = model(input)


index = output.data.numpy().argmax()
return index


def class_mapping(index):
mapping=open('class_mapping.txt','r')
class_map={}
for line in mapping:
    l=line.strip('\n').split('~')
    class_map[l[1]]=l[0]



  
  
    
    
  
  



[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 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/phung/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’
[phung@archlinux SqueezeNet-Pruning]$