title: Size Mismatch Runtime Error When Trying to Load a PyTorch Model
body: <p>Below is the code I am trying to run. <code>fasterrcnn_foodtracker.pth</code> is the already trained model I am trying to load with PyTorch.</p>
  <pre class="lang-py prettyprint-override"><code>import torch
  import torchvision
  import cv2
  
  model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)
  
  path = '/home/amir/PycharmProjects/Food-Recognition/fasterrcnn_foodtracker.pth'
  model.load_state_dict(torch.load(path, map_location=torch.device('cpu')), strict=False)
  model.eval()
  
  img = cv2.imread('twodishes.jpg')
  prediction = model([img])
  print(prediction)
  </code></pre>
  <p>A runtime error appears with a size mismatch.</p>
  <pre><code>RuntimeError: Error(s) in loading state_dict for FasterRCNN:
      size mismatch for roi_heads.box_predictor.cls_score.weight: copying a param with shape torch.Size([100, 1024]) from checkpoint, the shape in current model is torch.Size([91, 1024]).
      size mismatch for roi_heads.box_predictor.cls_score.bias: copying a param with shape torch.Size([100]) from checkpoint, the shape in current model is torch.Size([91]).
      size mismatch for roi_heads.box_predictor.bbox_pred.weight: copying a param with shape torch.Size([400, 1024]) from checkpoint, the shape in current model is torch.Size([364, 1024]).
      size mismatch for roi_heads.box_predictor.bbox_pred.bias: copying a param with shape torch.Size([400]) from checkpoint, the shape in current model is torch.Size([364]).
  </code></pre>