title: pytorch vgg model test on one image
body: <p>I've trained a vgg model, this is how I transformed the test data</p>
  
  <pre><code>test_transform_2= transforms.Compose([transforms.RandomResizedCrop(224), 
                                       transforms.ToTensor()])
  
  test_data = datasets.ImageFolder(test_dir, transform=test_transform_2)
  </code></pre>
  
  <p>the model's finished training now I want to test it on a single image</p>
  
  <pre><code>from scipy import misc
  
  test_image = misc.imread('flower_data/valid/1/image_06739.jpg')
  vgg16(torch.from_numpy(test_image))
  </code></pre>
  
  <h2>Error</h2>
  
  <pre><code>---------------------------------------------------------------------------
  RuntimeError                              Traceback (most recent call last)
  &lt;ipython-input-60-b83587325fea&gt; in &lt;module&gt;
  ----&gt; 1 vgg16(torch.from_numpy(test_image))
  
  c:\users\sam\mydocu~1\code\envs\data-science\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
      475             result = self._slow_forward(*input, **kwargs)
      476         else:
  --&gt; 477             result = self.forward(*input, **kwargs)
      478         for hook in self._forward_hooks.values():
      479             hook_result = hook(self, input, result)
  
  c:\users\sam\mydocu~1\code\envs\data-science\lib\site-packages\torchvision\models\vgg.py in forward(self, x)
       40 
       41     def forward(self, x):
  ---&gt; 42         x = self.features(x)
       43         x = x.view(x.size(0), -1)
       44         x = self.classifier(x)
  
  c:\users\sam\mydocu~1\code\envs\data-science\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
      475             result = self._slow_forward(*input, **kwargs)
      476         else:
  --&gt; 477             result = self.forward(*input, **kwargs)
      478         for hook in self._forward_hooks.values():
      479             hook_result = hook(self, input, result)
  
  c:\users\sam\mydocu~1\code\envs\data-science\lib\site-packages\torch\nn\modules\container.py in forward(self, input)
       89     def forward(self, input):
       90         for module in self._modules.values():
  ---&gt; 91             input = module(input)
       92         return input
       93 
  
  c:\users\sam\mydocu~1\code\envs\data-science\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
      475             result = self._slow_forward(*input, **kwargs)
      476         else:
  --&gt; 477             result = self.forward(*input, **kwargs)
      478         for hook in self._forward_hooks.values():
      479             hook_result = hook(self, input, result)
  
  c:\users\sam\mydocu~1\code\envs\data-science\lib\site-packages\torch\nn\modules\conv.py in forward(self, input)
      299     def forward(self, input):
      300         return F.conv2d(input, self.weight, self.bias, self.stride,
  --&gt; 301                         self.padding, self.dilation, self.groups)
      302 
      303 
  
  RuntimeError: Expected 4-dimensional input for 4-dimensional weight [64, 3, 3, 3], but got input of size [628, 500, 3] instead
  </code></pre>
  
  <p>I can tell I need to shape the input, however I don't know how to based on the way it seems to expect the input to be inform of a batch.</p>