after looking at a few other blogs, this seemed to work for me

  
    
    
    RuntimeError: Given groups=1, weight of size [64, 3, 7, 7], expected input[3, 1, 224, 224] to have 3 channels, but got 1 channels instead vision
  
  
    I see a couple of such posts in forum but I have hardtime generalizing it to my own problem. Here’s the error: 
torch.Size([3, 1, 224, 224])
Traceback (most recent call last):
  File "test_loocv.py", line 245, in <module>
    output = model_ft(test_data)
  File "/scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages/torchvis…
  



  
    
    
    How to extract features of an image from a trained model 
  
  
    resnet18 doesn’t have a classifier field, and the solution I gave was for vgg.
  


new_classifier = nn.Sequential(*list(loaded_model.children())[:-1])
model = new_classifier
outputs = model(input_image.unsqueeze_(0).cuda())
outputs = outputs.view(-1)