RuntimeError: Error(s) in loading state_dict for Inception3:

Saifeddine_Barkia: <p>Hello, I have trained my model using this code</p>
<pre><code class="lang-auto">!python train_bap.py train\
    --model-name inception \
    --batch-size 12 \
    --dataset car \
    --image-size 512 \
    --input-size 448 \
    --checkpoint-path checkpoint/car \
    --optim sgd \
    --scheduler step \
    --lr 0.001 \
    --momentum 0.9 \
    --weight-decay 1e-5 \
    --workers 4 \
    --parts 32 \
    --epochs 80 \
    --use-gpu \
    --multi-gpu \
    --gpu-ids 0 \
</code></pre>
<p>it takes much time so I wanted to test the model. I interrupted the model at epoch 11. it gave me the interruption error which I think is normal:</p>
<pre><code class="lang-auto">Epoch: [11][300/679]	Time 1.259 (1.257)	Data 0.000 (0.005)	Loss 0.3933 (0.5248)	Prec@1 100.000 (98.754)	Prec@5 100.000 (100.000)
loss1,loss2,loss3,feature_center_loss 0.07012923806905746 0.05921419337391853 0.15795135498046875 0.2975512146949768
Traceback (most recent call last):
  File "train_bap.py", line 210, in &lt;module&gt;
    train()
  File "train_bap.py", line 145, in train
    train_prec, train_loss = engine.train(state, e)
  File "/content/WS_DAN_PyTorch-master/utils/engine.py", line 73, in train
    loss.backward()
  File "/usr/local/lib/python3.6/site-packages/torch/tensor.py", line 198, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/usr/local/lib/python3.6/site-packages/torch/autograd/__init__.py", line 100, in backward
    allow_unreachable=True)  # allow_unreachable flag
KeyboardInterrupt
</code></pre>
<p>When I tried to test the model using this code</p>
<pre><code class="lang-auto">%cd /content/WS_DAN_PyTorch-master/
!python train_bap.py test\
    --model-name inception \
    --batch-size 12 \
    --dataset car \
    --image-size 512 \
    --input-size 448 \
    --checkpoint-path checkpoint/car/model_best.pth.tar \
    --workers 4 \
    --parts 32 \
    --use-gpu \
    --multi-gpu \
    --gpu-ids 0 \
</code></pre>
<p>it gave me that error:</p>
<pre><code class="lang-auto">Traceback (most recent call last):
  File "train_bap.py", line 212, in &lt;module&gt;
    test()
  File "train_bap.py", line 196, in test
    net.load_state_dict(torch.load(config.checkpoint_path)['state_dict'])
  File "/usr/local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 847, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Inception3:
	Missing key(s) in state_dict: "Conv2d_1a_3x3.conv.weight", "Conv2d_1a_3x3.bn.weight", "Conv2d_1a_3x3.bn.bias", "Conv2d_1a_3x3.bn.running_mean", "Conv2d_1a_3x3.bn.running_var", "Conv2d_2a_3x3.conv.weight", "Conv2d_2a_3x3.bn.weight", "Conv2d_2a_3x3.bn.bias", "Conv2d_2a_3x3.bn.running_mean", "Conv2d_2a_3x3.bn.running_var", "Conv2d_2b_3x3.conv.weight", "Conv2d_2b_3x3.bn.weight", "Conv2d_2b_3x3.bn.bias", "Conv2d_2b_3x3.bn.running_mean", "Conv2d_2b_3x3.bn.running_var", "Conv2d_3b_1x1.conv.weight", "Conv2d_3b_1x1.bn.weight", "Conv2d_3b_1x1.bn.bias", "Conv2d_3b_1x1.bn.running_mean", "Conv2d_3b_1x1.bn.running_var", "Conv2d_4a_3x3.conv.weight", "Conv2d_4a_3x3.bn.weight", "Conv2d_4a_3x3.bn.bias", "Conv2d_4a_3x3.bn.running_mean", "Conv2d_4a_3x3.bn.running_var", "Mixed_5b.branch1x1.conv.weight", "Mixed_5b.branch1x1.bn.weight", "Mixed_5b.branch1x1.bn.bias", "Mixed_5b.branch1x1.bn.running_mean", "Mixed_5b.branch1x1.bn.running_var", "Mixed_5b.branch5x5_1.conv.weight", "Mixed_5b.branch5x5_1.bn.weight", "Mixed_5b.branch5x5_1.bn.bias", "Mixed_5b.branch5x5_1.bn.running_mean", "Mixed_5b.branch5x5_1.bn.running_var", "Mixed_5b.branch5x5_2.conv.weight", "Mixed_5b.branch5x5_2.bn.weight", "Mixed_5b.branch5x5_2.bn.bias", "Mixed_5b.branch5x5_2.bn.running_mean", "Mixed_5b.branch5x5_2.bn.running_var", "Mixed_5b.branch3x3dbl_1.conv.weight", "Mixed_5b.branch3x3dbl_1.bn.weight", "Mixed_5b.branch3x3dbl_1.bn.bias", "Mixed_5b.branch3x3dbl_1.bn.running_mean", "Mixed_5b.branch3x3dbl_1.bn.running_var", "Mixed_5b.branch3x3dbl_2.conv.weight", "Mixed_5b.branch3x3dbl_2.bn.weight", "Mixed_5b.branch3x3dbl_2.bn.bias", "Mixed_5b.branch3x3dbl_2.bn.running_mean", "Mixed_5b.branch3x3dbl_2.bn.running_var", "Mixed_5b.branch3x3dbl_3.conv.weight", "Mixed_5b.branch3x3dbl_3.bn.weight", "Mixed_5b.branch3x3dbl_3.bn.bias", "Mixed_5b.branch3x3dbl_3.bn.running_mean", "Mixed_5b.branch3x3dbl_3.bn.running_var", "Mixed_5b.branch_pool.conv.weight", "Mixed_5b.branch_pool.bn.weight", "Mixed_5b.branch_pool.bn.bias", "Mixed_5b.branch_pool.bn.running_mean", "Mixed_5b.branch_pool.bn.running_var", "Mixed_5c.branch1x1.conv.weight", "Mixed_5c.branch1x1.bn.weight", "Mixed_5c.branch1x1.bn.bias", "Mixed_5c.branch1x1.bn.running_mean", "Mixed_5c.branch1x1.bn.running_var", "Mixed_5c.branch5x5_1.conv.weight", "Mixed_5c.branch5x5_1.bn.weight", "Mixed_5c.branch5x5_1.bn.bias", "Mixed_5c.branch5x5_1.bn.running_mean", "Mixed_5c.branch5x5_1.bn.running_var", "Mixed_5c.branch5x5_2.conv.weight", "Mixed_5c.branch5x5_2.bn.weight", "Mixed_5c.branch5x5_2.bn.bias", "Mixed_5c.branch5x5_2.bn.running_mean", "Mixed_5c.branch5x5_2.bn.running_var", "Mixed_5c.branch3x3dbl_1.conv.weight", "Mixed_5c.branch3x3dbl_1.bn.weight", "Mixed_5c.branch3x3dbl_1.bn.bias", "Mixed_5c.branch3x3dbl_1.bn.running_mean", "Mixed_5c.branch3x3dbl_1.bn.running_var", "Mixed_5c.branch3x3dbl_2.conv.weight", "Mixed_5c.branch3x3dbl_2.bn.weight", "Mixed_5c.branch3x3dbl_2.bn.bias", "Mixed_5c.branch3x3dbl_2.bn.running_mean", "Mixed_5c.branch3x3dbl_2.bn.running_var", "Mixed_5c.branch3x3dbl_3.conv.weight", "Mixed_5c.branch3x3dbl_3.bn.weight", "Mixed_5c.branch3x3dbl_3.bn.bias", "Mixed_5c.branch3x3dbl_3.bn.running_mean", "Mixed_5c.branch3x3dbl_3.bn.running_var", "Mixed_5c.branch_pool.conv.weight", "Mixed_5c.branch_pool.bn.weight", "Mixed_5c.branch_pool.bn.bias", "Mixed_5c.branch_pool.bn.running_mean", "Mixed_5c.branch_pool.bn.running_var", "Mixed_5d.branch1x1.conv.weight", "Mixed_5d.branch1x1.bn.weight", "Mixed_5d.branch1x1.bn.bias", "Mixed_5d.branch1x1.bn.running_mean", "Mixed_5d.branch1x1.bn.running_var", "Mixed_5d.branch5x5_1.conv.weight", "Mixed_5d.branch5x5_1.bn.weight", "Mixed_5d.branch5x5_1.bn.bias", "Mixed_5d.branch5x5_1.bn.running_mean", "Mixed_5d.branch5x5_1.bn.running_var", "Mixed_5d.branch5x5_2.conv.weight", "Mixed_5d.branch5x5_2.bn.weight", "Mixed_5d.branch5x5_2.bn.bias", "Mixed_5d.branch5x5_2.bn.running_mean", "Mixed_5d.branch5x5_2.bn.running_var", "Mixed_5d.branch3x3dbl_1.conv.weight", "Mixed_5d.branch3x3dbl_1.bn.weight", "Mixed_5d.branch3x3dbl_1.bn.bias", "Mixed_5d.branch3x3dbl_1.bn.running_mean", "Mixed_5d.branch3x3dbl_1.bn.running_var", "Mixed_5d.branch3x3dbl_2.conv.weight", "Mixed_5d.branch3x3dbl_2.bn.weight", "Mixed_5d.branch3x3dbl_2.bn.bias", "Mixed_5d.branch3x3dbl_2.bn.running_mean", "Mixed_5d.branch3x3dbl_2.bn.running_var", "Mixed_5d.branch3x3dbl_3.conv.weight", "Mixed_5d.branch3x3dbl_3.bn.weight", "Mixed_5d.branch3x3dbl_3.bn.bias", "Mixed_5d.branch3x3dbl_3.bn.running_mean", "Mixed_5d.branch3x3dbl_3.bn.running_var", "Mixed_5d.branch_pool.conv.weight", "Mixed_5d.branch_pool.bn.weight", "Mixed_5d.branch_pool.bn.bias", "Mixed_5d.branch_pool.bn.running_mean", "Mixed_5d.branch_pool.bn.running_var", "Mixed_6a.branch3x3.conv.weight", "Mixed_6a.branch3x3.bn.weight", "Mixed_6a.branch3x3.bn.bias", "Mixed_6a.branch3x3.bn.running_mean", "Mixed_6a.branch3x3.bn.running_var", "Mixed_6a.branch3x3dbl_1.conv.weight", "Mixed_6a.branch3x3dbl_1.bn.weight", "Mixed_6a.branch3x3dbl_1.bn.bias", "Mixed_6a.branch3x3dbl_1.bn.running_mean", "Mixed_6a.branch3x3dbl_1.bn.running_var", "Mixed_6a.branch3x3dbl_2.conv.weight", "Mixed_6a.branch3x3dbl_2.bn.weight", "Mixed_6a.branch3x3dbl_2.bn.bias", "Mixed_6a.branch3x3dbl_2.bn.running_mean", "Mixed_6a.branch3x3dbl_2.bn.running_var", "Mixed_6a.branch3x3dbl_3.conv.weight", "Mixed_6a.branch3x3dbl_3.bn.weight", "Mixed_6a.branch3x3dbl_3.bn.bias", "Mixed_6a.branch3x3dbl_3.bn.running_mean", "Mixed_6a.branch3x3dbl_3.bn.running_var", "Mixed_6b.branch1x1.conv.weight", "Mixed_6b.branch1x1.bn.weight", "Mixed_6b.branch1x1.bn.bias", "Mixed_6b.branch1x1.bn.running_mean", "Mixed_6b.branch1x1.bn.running_var", "Mixed_6b.branch7x7_1.conv.weight", "Mixed_6b.branch7x7_1.bn.weight", "Mixed_6b.branch7x7_1.bn.bias", "Mixed_6b.branch7x7_1.bn.running_mean", "Mixed_6b.branch7x7_1.bn.running_var", "Mixed_6b.branch7x7_2.conv.weight", "Mixed_6b.branch7x7_2.bn.weight", "Mixed_6b.branch7x7_2.bn.bias", "Mixed_6b.branch7x7_2.bn.running_mean", "Mixed_6b.branch7x7_2.bn.running_var", "Mixed_6b.branch7x7_3.conv.weight", "Mixed_6b.branch7x7_3.bn.weight", "Mixed_6b.branch7x7_3.bn.bias", "Mixed_6b.branch7x7_3.bn.running_mean", "Mixed_6b.branch7x7_3.bn.running_var", "Mixed_6b.branch7x7dbl_1.conv.weight", "Mixed_6b.branch7x7dbl_1.bn.weight", "Mixed_6b.branch7x7dbl_1.bn.bias", "Mixed_6b.branch7x7dbl_1.bn.running_mean", "Mixed_6b.branch7x7dbl_1.bn.running_var", "Mixed_6b.branch7x7dbl_2.conv.weight", "Mixed_6b.branch7x7dbl_2.bn.weight", "Mixed_6b.branch7x7dbl_2.bn.bias", "Mixed_6b.branch7x7dbl_2.bn.running_mean", "Mixed_6b.branch7x7dbl_2.bn.running_var", "Mixed_6b.branch7x7dbl_3.conv.weight", "Mixed_6b.branch7x7dbl_3.bn.weight", "Mixed_6b.branch7x7dbl_3.bn.bias", "Mixed_6b.branch7x7dbl_3.bn.running_mean", "Mixed_6b.branch7x7dbl_3.bn.running_var", "Mixed_6b.branch7x7dbl_4.conv.weight", "Mixed_6b.branch7x7dbl_4.bn.weight", "Mixed_6b.branch7x7dbl_4.bn.bias", "Mixed_6b.branch7x7dbl_4.bn.running_mean", "Mixed_6b.branch7x7dbl_4.bn.running_var", "Mixed_6b.branch7x7dbl_5.conv.weight", "Mixed_6b.branch7x7dbl_5.bn.weight", "Mixed_6b.branch7x7dbl_5.bn.bias", "Mixed_6b.branch7x7dbl_5.bn.running_mean", "Mixed_6b.branch7x7dbl_5.bn.running_var", "Mixed_6b.branch_pool.conv.weight", "Mixed_6b.branch_pool.bn.weight", "Mixed_6b.branch_pool.bn.bias", "Mixed_6b.branch_pool.bn.running_mean", "Mixed_6b.branch_pool.bn.running_var", "Mixed_6c.branch1x1.conv.weight", "Mixed_6c.branch1x1.bn.weight", "Mixed_6c.branch1x1.bn.bias", "Mixed_6c.branch1x1.bn.running_mean", "Mixed_6c.branch1x1.bn.running_var", "Mixed_6c.branch7x7_1.conv.weight", "Mixed_6c.branch7x7_1.bn.weight", "Mixed_6c.branch7x7_1.bn.bias", "Mixed_6c.branch7x7_1.bn.running_mean", "Mixed_6c.branch7x7_1.bn.running_var", "Mixed_6c.branch7x7_2.conv.weight", "Mixed_6c.branch7x7_2.bn.weight", "Mixed_6c.branch7x7_2.bn.bias", "Mixed_6c.branch7x7_2.bn.running_mean", "Mixed_6c.branch7x7_2.bn.running_var", "Mixed_6c.branch7x7_3.conv.weight", "Mixed_6c.branch7x7_3.bn.weight", "Mixed_6c.branch7x7_3.bn.bias", "Mixed_6c.branch7x7_3.bn.running_mean", "Mixed_6c.branch7x7_3.bn.running_var", "Mixed_6c.branch7x7dbl_1.conv.weight", "Mixed_6c.branch7x7dbl_1.bn.weight", "Mixed_6c.branch7x7dbl_1.bn.bias", "Mixed_6c.branch7x7dbl_1.bn.running_mean", "Mixed_6c.branch7x7dbl_1.bn.running_var", "Mixed_6c.branch7x7dbl_2.conv.weight", "Mixed_6c.branch7x7dbl_2.bn.weight", "Mixed_6c.branch7x7dbl_2.bn.bias", "Mixed_6c.branch7x7dbl_2.bn.running_mean", "Mixed_6c.branch7x7dbl_2.bn.running_var", "Mixed_6c.branch7x7dbl_3.conv.weight", "Mixed_6c.branch7x7dbl_3.bn.weight", "Mixed_6c.branch7x7dbl_3.bn.bias", "Mixed_6c.branch7x7dbl_3.bn.running_mean", "Mixed_6c.branch7x7dbl_3.bn.running_var", "Mixed_6c.branch7x7dbl_4.conv.weight", "Mixed_6c.branch7x7dbl_4.bn.weight", "Mixed_6c.branch7x7dbl_4.bn.bias", "Mixed_6c.branch7x7dbl_4.bn.running_mean", "Mixed_6c.branch7x7dbl_4.bn.running_var", "Mixed_6c.branch7x7dbl_5.conv.weight", "Mixed_6c.branch7x7dbl_5.bn.weight", "Mixed_6c.branch7x7dbl_5.bn.bias", "Mixed_6c.branch7x7dbl_5.bn.running_mean", "Mixed_6c.branch7x7dbl_5.bn.running_var", "Mixed_6c.branch_pool.conv.weight", "Mixed_6c.branch_pool.bn.weight", "Mixed_6c.branch_pool.bn.bias", "Mixed_6c.branch_pool.bn.running_mean", "Mixed_6c.branch_pool.bn.running_var", "Mixed_6d.branch1x1.conv.weight", "Mixed_6d.branch1x1.bn.weight", "Mixed_6d.branch1x1.bn.bias", "Mixed_6d.branch1x1.bn.running_mean", "Mixed_6d.branch1x1.bn.running_var", "Mixed_6d.branch7x7_1.conv.weight", "Mixed_6d.branch7x7_1.bn.weight", "Mixed_6d.branch7x7_1.bn.bias", "Mixed_6d.branch7x7_1.bn.running_mean", "Mixed_6d.branch7x7_1.bn.running_var", "Mixed_6d.branch7x7_2.conv.weight", "Mixed_6d.branch7x7_2.bn.weight", "Mixed_6d.branch7x7_2.bn.bias", "Mixed_6d.branch7x7_2.bn.running_mean", "Mixed_6d.branch7x7_2.bn.running_var", "Mixed_6d.branch7x7_3.conv.weight", "Mixed_6d.branch7x7_3.bn.weight", "Mixed_6d.branch7x7_3.bn.bias", "Mixed_6d.branch7x7_3.bn.running_mean", "Mixed_6d.branch7x7_3.bn.running_var", "Mixed_6d.branch7x7dbl_1.conv.weight", "Mixed_6d.branch7x7dbl_1.bn.weight", "Mixed_6d.branch7x7dbl_1.bn.bias", "Mixed_6d.branch7x7dbl_1.bn.running_mean", "Mixed_6d.branch7x7dbl_1.bn.running_var", "Mixed_6d.branch7x7dbl_2.conv.weight", "Mixed_6d.branch7x7dbl_2.bn.weight", "Mixed_6d.branch7x7dbl_2.bn.bias", "Mixed_6d.branch7x7dbl_2.bn.running_mean", "Mixed_6d.branch7x7dbl_2.bn.running_var", "Mixed_6d.branch7x7dbl_3.conv.weight", "Mixed_6d.branch7x7dbl_3.bn.weight", "Mixed_6d.branch7x7dbl_3.bn.bias", "Mixed_6d.branch7x7dbl_3.bn.running_mean", "Mixed_6d.branch7x7dbl_3.bn.running_var", "Mixed_6d.branch7x7dbl_4.conv.weight", "Mixed_6d.branch7x7dbl_4.bn.weight", "Mixed_6d.branch7x7dbl_4.bn.bias", "Mixed_6d.branch7x7dbl_4.bn.running_mean", "Mixed_6d.branch7x7dbl_4.bn.running_var", "Mixed_6d.branch7x7dbl_5.conv.weight", "Mixed_6d.branch7x7dbl_5.bn.weight", "Mixed_6d.branch7x7dbl_5.bn.bias", "Mixed_6d.branch7x7dbl_5.bn.running_mean", "Mixed_6d.branch7x7dbl_5.bn.running_var", "Mixed_6d.branch_pool.conv.weight", "Mixed_6d.branch_pool.bn.weight", "Mixed_6d.branch_pool.bn.bias", "Mixed_6d.branch_pool.bn.running_mean", "Mixed_6d.branch_pool.bn.running_var", "Mixed_6e.branch1x1.conv.weight", "Mixed_6e.branch1x1.bn.weight", "Mixed_6e.branch1x1.bn.bias", "Mixed_6e.branch1x1.bn.running_mean", "Mixed_6e.branch1x1.bn.running_var", "Mixed_6e.branch7x7_1.conv.weight", "Mixed_6e.branch7x7_1.bn.weight", "Mixed_6e.branch7x7_1.bn.bias", "Mixed_6e.branch7x7_1.bn.running_mean", "Mixed_6e.branch7x7_1.bn.running_var", "Mixed_6e.branch7x7_2.conv.weight", "Mixed_6e.branch7x7_2.bn.weight", "Mixed_6e.branch7x7_2.bn.bias", "Mixed_6e.branch7x7_2.bn.running_mean", "Mixed_6e.branch7x7_2.bn.running_var", "Mixed_6e.branch7x7_3.conv.weight", "Mixed_6e.branch7x7_3.bn.weight", "Mixed_6e.branch7x7_3.bn.bias", "Mixed_6e.branch7x7_3.bn.running_mean", "Mixed_6e.branch7x7_3.bn.running_var", "Mixed_6e.branch7x7dbl_1.conv.weight", "Mixed_6e.branch7x7dbl_1.bn.weight", "Mixed_6e.branch7x7dbl_1.bn.bias", "Mixed_6e.branch7x7dbl_1.bn.running_mean", "Mixed_6e.branch7x7dbl_1.bn.running_var", "Mixed_6e.branch7x7dbl_2.conv.weight", "Mixed_6e.branch7x7dbl_2.bn.weight", "Mixed_6e.branch7x7dbl_2.bn.bias", "Mixed_6e.branch7x7dbl_2.bn.running_mean", "Mixed_6e.branch7x7dbl_2.bn.running_var", "Mixed_6e.branch7x7dbl_3.conv.weight", "Mixed_6e.branch7x7dbl_3.bn.weight", "Mixed_6e.branch7x7dbl_3.bn.bias", "Mixed_6e.branch7x7dbl_3.bn.running_mean", "Mixed_6e.branch7x7dbl_3.bn.running_var", "Mixed_6e.branch7x7dbl_4.conv.weight", "Mixed_6e.branch7x7dbl_4.bn.weight", "Mixed_6e.branch7x7dbl_4.bn.bias", "Mixed_6e.branch7x7dbl_4.bn.running_mean", "Mixed_6e.branch7x7dbl_4.bn.running_var", "Mixed_6e.branch7x7dbl_5.conv.weight", "Mixed_6e.branch7x7dbl_5.bn.weight", "Mixed_6e.branch7x7dbl_5.bn.bias", "Mixed_6e.branch7x7dbl_5.bn.running_mean", "Mixed_6e.branch7x7dbl_5.bn.running_var", "Mixed_6e.branch_pool.conv.weight", "Mixed_6e.branch_pool.bn.weight", "Mixed_6e.branch_pool.bn.bias", "Mixed_6e.branch_pool.bn.running_mean", "Mixed_6e.branch_pool.bn.running_var", "Mixed_7a.branch3x3_1.conv.weight", "Mixed_7a.branch3x3_1.bn.weight", "Mixed_7a.branch3x3_1.bn.bias", "Mixed_7a.branch3x3_1.bn.running_mean", "Mixed_7a.branch3x3_1.bn.running_var", "Mixed_7a.branch3x3_2.conv.weight", "Mixed_7a.branch3x3_2.bn.weight", "Mixed_7a.branch3x3_2.bn.bias", "Mixed_7a.branch3x3_2.bn.running_mean", "Mixed_7a.branch3x3_2.bn.running_var", "Mixed_7a.branch7x7x3_1.conv.weight", "Mixed_7a.branch7x7x3_1.bn.weight", "Mixed_7a.branch7x7x3_1.bn.bias", "Mixed_7a.branch7x7x3_1.bn.running_mean", "Mixed_7a.branch7x7x3_1.bn.running_var", "Mixed_7a.branch7x7x3_2.conv.weight", "Mixed_7a.branch7x7x3_2.bn.weight", "Mixed_7a.branch7x7x3_2.bn.bias", "Mixed_7a.branch7x7x3_2.bn.running_mean", "Mixed_7a.branch7x7x3_2.bn.running_var", "Mixed_7a.branch7x7x3_3.conv.weight", "Mixed_7a.branch7x7x3_3.bn.weight", "Mixed_7a.branch7x7x3_3.bn.bias", "Mixed_7a.branch7x7x3_3.bn.running_mean", "Mixed_7a.branch7x7x3_3.bn.running_var", "Mixed_7a.branch7x7x3_4.conv.weight", "Mixed_7a.branch7x7x3_4.bn.weight", "Mixed_7a.branch7x7x3_4.bn.bias", "Mixed_7a.branch7x7x3_4.bn.running_mean", "Mixed_7a.branch7x7x3_4.bn.running_var", "fc_new.weight", "fc_new.bias". 
	Unexpected key(s) in state_dict: "module.Conv2d_1a_3x3.conv.weight", "module.Conv2d_1a_3x3.bn.weight", "module.Conv2d_1a_3x3.bn.bias", "module.Conv2d_1a_3x3.bn.running_mean", "module.Conv2d_1a_3x3.bn.running_var", "module.Conv2d_1a_3x3.bn.num_batches_tracked", "module.Conv2d_2a_3x3.conv.weight", "module.Conv2d_2a_3x3.bn.weight", "module.Conv2d_2a_3x3.bn.bias", "module.Conv2d_2a_3x3.bn.running_mean", "module.Conv2d_2a_3x3.bn.running_var", "module.Conv2d_2a_3x3.bn.num_batches_tracked", "module.Conv2d_2b_3x3.conv.weight", "module.Conv2d_2b_3x3.bn.weight", "module.Conv2d_2b_3x3.bn.bias", "module.Conv2d_2b_3x3.bn.running_mean", "module.Conv2d_2b_3x3.bn.running_var", "module.Conv2d_2b_3x3.bn.num_batches_tracked", "module.Conv2d_3b_1x1.conv.weight", "module.Conv2d_3b_1x1.bn.weight", "module.Conv2d_3b_1x1.bn.bias", "module.Conv2d_3b_1x1.bn.running_mean", "module.Conv2d_3b_1x1.bn.running_var", "module.Conv2d_3b_1x1.bn.num_batches_tracked", "module.Conv2d_4a_3x3.conv.weight", "module.Conv2d_4a_3x3.bn.weight", "module.Conv2d_4a_3x3.bn.bias", "module.Conv2d_4a_3x3.bn.running_mean", "module.Conv2d_4a_3x3.bn.running_var", "module.Conv2d_4a_3x3.bn.num_batches_tracked", "module.Mixed_5b.branch1x1.conv.weight", "module.Mixed_5b.branch1x1.bn.weight", "module.Mixed_5b.branch1x1.bn.bias", "module.Mixed_5b.branch1x1.bn.running_mean", "module.Mixed_5b.branch1x1.bn.running_var", "module.Mixed_5b.branch1x1.bn.num_batches_tracked", "module.Mixed_5b.branch5x5_1.conv.weight", "module.Mixed_5b.branch5x5_1.bn.weight", "module.Mixed_5b.branch5x5_1.bn.bias", "module.Mixed_5b.branch5x5_1.bn.running_mean", "module.Mixed_5b.branch5x5_1.bn.running_var", "module.Mixed_5b.branch5x5_1.bn.num_batches_tracked", "module.Mixed_5b.branch5x5_2.conv.weight", "module.Mixed_5b.branch5x5_2.bn.weight", "module.Mixed_5b.branch5x5_2.bn.bias", "module.Mixed_5b.branch5x5_2.bn.running_mean", "module.Mixed_5b.branch5x5_2.bn.running_var", "module.Mixed_5b.branch5x5_2.bn.num_batches_tracked", "module.Mixed_5b.branch3x3dbl_1.conv.weight", "module.Mixed_5b.branch3x3dbl_1.bn.weight", "module.Mixed_5b.branch3x3dbl_1.bn.bias", "module.Mixed_5b.branch3x3dbl_1.bn.running_mean", "module.Mixed_5b.branch3x3dbl_1.bn.running_var", "module.Mixed_5b.branch3x3dbl_1.bn.num_batches_tracked", "module.Mixed_5b.branch3x3dbl_2.conv.weight", "module.Mixed_5b.branch3x3dbl_2.bn.weight", "module.Mixed_5b.branch3x3dbl_2.bn.bias", "module.Mixed_5b.branch3x3dbl_2.bn.running_mean", "module.Mixed_5b.branch3x3dbl_2.bn.running_var", "module.Mixed_5b.branch3x3dbl_2.bn.num_batches_tracked", "module.Mixed_5b.branch3x3dbl_3.conv.weight", "module.Mixed_5b.branch3x3dbl_3.bn.weight", "module.Mixed_5b.branch3x3dbl_3.bn.bias", "module.Mixed_5b.branch3x3dbl_3.bn.running_mean", "module.Mixed_5b.branch3x3dbl_3.bn.running_var", "module.Mixed_5b.branch3x3dbl_3.bn.num_batches_tracked", "module.Mixed_5b.branch_pool.conv.weight", "module.Mixed_5b.branch_pool.bn.weight", "module.Mixed_5b.branch_pool.bn.bias", "module.Mixed_5b.branch_pool.bn.running_mean", "module.Mixed_5b.branch_pool.bn.running_var", "module.Mixed_5b.branch_pool.bn.num_batches_tracked", "module.Mixed_5c.branch1x1.conv.weight", "module.Mixed_5c.branch1x1.bn.weight", "module.Mixed_5c.branch1x1.bn.bias", "module.Mixed_5c.branch1x1.bn.running_mean", "module.Mixed_5c.branch1x1.bn.running_var", "module.Mixed_5c.branch1x1.bn.num_batches_tracked", "module.Mixed_5c.branch5x5_1.conv.weight", "module.Mixed_5c.branch5x5_1.bn.weight", "module.Mixed_5c.branch5x5_1.bn.bias", "module.Mixed_5c.branch5x5_1.bn.running_mean", "module.Mixed_5c.branch5x5_1.bn.running_var", "module.Mixed_5c.branch5x5_1.bn.num_batches_tracked", "module.Mixed_5c.branch5x5_2.conv.weight", "module.Mixed_5c.branch5x5_2.bn.weight", "module.Mixed_5c.branch5x5_2.bn.bias", "module.Mixed_5c.branch5x5_2.bn.running_mean", "module.Mixed_5c.branch5x5_2.bn.running_var", "module.Mixed_5c.branch5x5_2.bn.num_batches_tracked", "module.Mixed_5c.branch3x3dbl_1.conv.weight", "module.Mixed_5c.branch3x3dbl_1.bn.weight", "module.Mixed_5c.branch3x3dbl_1.bn.bias", "module.Mixed_5c.branch3x3dbl_1.bn.running_mean", "module.Mixed_5c.branch3x3dbl_1.bn.running_var", "module.Mixed_5c.branch3x3dbl_1.bn.num_batches_tracked", "module.Mixed_5c.branch3x3dbl_2.conv.weight", "module.Mixed_5c.branch3x3dbl_2.bn.weight", "module.Mixed_5c.branch3x3dbl_2.bn.bias", "module.Mixed_5c.branch3x3dbl_2.bn.running_mean", "module.Mixed_5c.branch3x3dbl_2.bn.running_var", "module.Mixed_5c.branch3x3dbl_2.bn.num_batches_tracked", "module.Mixed_5c.branch3x3dbl_3.conv.weight", "module.Mixed_5c.branch3x3dbl_3.bn.weight", "module.Mixed_5c.branch3x3dbl_3.bn.bias", "module.Mixed_5c.branch3x3dbl_3.bn.running_mean", "module.Mixed_5c.branch3x3dbl_3.bn.running_var", "module.Mixed_5c.branch3x3dbl_3.bn.num_batches_tracked", "module.Mixed_5c.branch_pool.conv.weight", "module.Mixed_5c.branch_pool.bn.weight", "module.Mixed_5c.branch_pool.bn.bias", "module.Mixed_5c.branch_pool.bn.running_mean", "module.Mixed_5c.branch_pool.bn.running_var", "module.Mixed_5c.branch_pool.bn.num_batches_tracked", "module.Mixed_5d.branch1x1.conv.weight", "module.Mixed_5d.branch1x1.bn.weight", "module.Mixed_5d.branch1x1.bn.bias", "module.Mixed_5d.branch1x1.bn.running_mean", "module.Mixed_5d.branch1x1.bn.running_var", "module.Mixed_5d.branch1x1.bn.num_batches_tracked", "module.Mixed_5d.branch5x5_1.conv.weight", "module.Mixed_5d.branch5x5_1.bn.weight", "module.Mixed_5d.branch5x5_1.bn.bias", "module.Mixed_5d.branch5x5_1.bn.running_mean", "module.Mixed_5d.branch5x5_1.bn.running_var", "module.Mixed_5d.branch5x5_1.bn.num_batches_tracked", "module.Mixed_5d.branch5x5_2.conv.weight", "module.Mixed_5d.branch5x5_2.bn.weight", "module.Mixed_5d.branch5x5_2.bn.bias", "module.Mixed_5d.branch5x5_2.bn.running_mean", "module.Mixed_5d.branch5x5_2.bn.running_var", "module.Mixed_5d.branch5x5_2.bn.num_batches_tracked", "module.Mixed_5d.branch3x3dbl_1.conv.weight", "module.Mixed_5d.branch3x3dbl_1.bn.weight", "module.Mixed_5d.branch3x3dbl_1.bn.bias", "module.Mixed_5d.branch3x3dbl_1.bn.running_mean", "module.Mixed_5d.branch3x3dbl_1.bn.running_var", "module.Mixed_5d.branch3x3dbl_1.bn.num_batches_tracked", "module.Mixed_5d.branch3x3dbl_2.conv.weight", "module.Mixed_5d.branch3x3dbl_2.bn.weight", "module.Mixed_5d.branch3x3dbl_2.bn.bias", "module.Mixed_5d.branch3x3dbl_2.bn.running_mean", "module.Mixed_5d.branch3x3dbl_2.bn.running_var", "module.Mixed_5d.branch3x3dbl_2.bn.num_batches_tracked", "module.Mixed_5d.branch3x3dbl_3.conv.weight", "module.Mixed_5d.branch3x3dbl_3.bn.weight", "module.Mixed_5d.branch3x3dbl_3.bn.bias", "module.Mixed_5d.branch3x3dbl_3.bn.running_mean", "module.Mixed_5d.branch3x3dbl_3.bn.running_var", "module.Mixed_5d.branch3x3dbl_3.bn.num_batches_tracked", "module.Mixed_5d.branch_pool.conv.weight", "module.Mixed_5d.branch_pool.bn.weight", "module.Mixed_5d.branch_pool.bn.bias", "module.Mixed_5d.branch_pool.bn.running_mean", "module.Mixed_5d.branch_pool.bn.running_var", "module.Mixed_5d.branch_pool.bn.num_batches_tracked", "module.Mixed_6a.branch3x3.conv.weight", "module.Mixed_6a.branch3x3.bn.weight", "module.Mixed_6a.branch3x3.bn.bias", "module.Mixed_6a.branch3x3.bn.running_mean", "module.Mixed_6a.branch3x3.bn.running_var", "module.Mixed_6a.branch3x3.bn.num_batches_tracked", "module.Mixed_6a.branch3x3dbl_1.conv.weight", "module.Mixed_6a.branch3x3dbl_1.bn.weight", "module.Mixed_6a.branch3x3dbl_1.bn.bias", "module.Mixed_6a.branch3x3dbl_1.bn.running_mean", "module.Mixed_6a.branch3x3dbl_1.bn.running_var", "module.Mixed_6a.branch3x3dbl_1.bn.num_batches_tracked", "module.Mixed_6a.branch3x3dbl_2.conv.weight", "module.Mixed_6a.branch3x3dbl_2.bn.weight", "module.Mixed_6a.branch3x3dbl_2.bn.bias", "module.Mixed_6a.branch3x3dbl_2.bn.running_mean", "module.Mixed_6a.branch3x3dbl_2.bn.running_var", "module.Mixed_6a.branch3x3dbl_2.bn.num_batches_tracked", "module.Mixed_6a.branch3x3dbl_3.conv.weight", "module.Mixed_6a.branch3x3dbl_3.bn.weight", "module.Mixed_6a.branch3x3dbl_3.bn.bias", "module.Mixed_6a.branch3x3dbl_3.bn.running_mean", "module.Mixed_6a.branch3x3dbl_3.bn.running_var", "module.Mixed_6a.branch3x3dbl_3.bn.num_batches_tracked", "module.Mixed_6b.branch1x1.conv.weight", "module.Mixed_6b.branch1x1.bn.weight", "module.Mixed_6b.branch1x1.bn.bias", "module.Mixed_6b.branch1x1.bn.running_mean", "module.Mixed_6b.branch1x1.bn.running_var", "module.Mixed_6b.branch1x1.bn.num_batches_tracked", "module.Mixed_6b.branch7x7_1.conv.weight", "module.Mixed_6b.branch7x7_1.bn.weight", "module.Mixed_6b.branch7x7_1.bn.bias", "module.Mixed_6b.branch7x7_1.bn.running_mean", "module.Mixed_6b.branch7x7_1.bn.running_var", "module.Mixed_6b.branch7x7_1.bn.num_batches_tracked", "module.Mixed_6b.branch7x7_2.conv.weight", "module.Mixed_6b.branch7x7_2.bn.weight", "module.Mixed_6b.branch7x7_2.bn.bias", "module.Mixed_6b.branch7x7_2.bn.running_mean", "module.Mixed_6b.branch7x7_2.bn.running_var", "module.Mixed_6b.branch7x7_2.bn.num_batches_tracked", "module.Mixed_6b.branch7x7_3.conv.weight", "module.Mixed_6b.branch7x7_3.bn.weight", "module.Mixed_6b.branch7x7_3.bn.bias", "module.Mixed_6b.branch7x7_3.bn.running_mean", "module.Mixed_6b.branch7x7_3.bn.running_var", "module.Mixed_6b.branch7x7_3.bn.num_batches_tracked", "module.Mixed_6b.branch7x7dbl_1.conv.weight", "module.Mixed_6b.branch7x7dbl_1.bn.weight", "module.Mixed_6b.branch7x7dbl_1.bn.bias", "module.Mixed_6b.branch7x7dbl_1.bn.running_mean", "module.Mixed_6b.branch7x7dbl_1.bn.running_var", "module.Mixed_6b.branch7x7dbl_1.bn.num_batches_tracked", "module.Mixed_6b.branch7x7dbl_2.conv.weight", "module.Mixed_6b.branch7x7dbl_2.bn.weight", "module.Mixed_6b.branch7x7dbl_2.bn.bias", "module.Mixed_6b.branch7x7dbl_2.bn.running_mean", "module.Mixed_6b.branch7x7dbl_2.bn.running_var", "module.Mixed_6b.branch7x7dbl_2.bn.num_batches_tracked", "module.Mixed_6b.branch7x7dbl_3.conv.weight", "module.Mixed_6b.branch7x7dbl_3.bn.weight", "module.Mixed_6b.branch7x7dbl_3.bn.bias", "module.Mixed_6b.branch7x7dbl_3.bn.running_mean", "module.Mixed_6b.branch7x7dbl_3.bn.running_var", "module.Mixed_6b.branch7x7dbl_3.bn.num_batches_tracked", "module.Mixed_6b.branch7x7dbl_4.conv.weight", "module.Mixed_6b.branch7x7dbl_4.bn.weight", "module.Mixed_6b.branch7x7dbl_4.bn.bias", "module.Mixed_6b.branch7x7dbl_4.bn.running_mean", "module.Mixed_6b.branch7x7dbl_4.bn.running_var", "module.Mixed_6b.branch7x7dbl_4.bn.num_batches_tracked", "module.Mixed_6b.branch7x7dbl_5.conv.weight", "module.Mixed_6b.branch7x7dbl_5.bn.weight", "module.Mixed_6b.branch7x7dbl_5.bn.bias", "module.Mixed_6b.branch7x7dbl_5.bn.running_mean", "module.Mixed_6b.branch7x7dbl_5.bn.running_var", "module.Mixed_6b.branch7x7dbl_5.bn.num_batches_tracked", "module.Mixed_6b.branch_pool.conv.weight", "module.Mixed_6b.branch_pool.bn.weight", "module.Mixed_6b.branch_pool.bn.bias", "module.Mixed_6b.branch_pool.bn.running_mean", "module.Mixed_6b.branch_pool.bn.running_var", "module.Mixed_6b.branch_pool.bn.num_batches_tracked", "module.Mixed_6c.branch1x1.conv.weight", "module.Mixed_6c.branch1x1.bn.weight", "module.Mixed_6c.branch1x1.bn.bias", "module.Mixed_6c.branch1x1.bn.running_mean", "module.Mixed_6c.branch1x1.bn.running_var", "module.Mixed_6c.branch1x1.bn.num_batches_tracked", "module.Mixed_6c.branch7x7_1.conv.weight", "module.Mixed_6c.branch7x7_1.bn.weight", "module.Mixed_6c.branch7x7_1.bn.bias", "module.Mixed_6c.branch7x7_1.bn.running_mean", "module.Mixed_6c.branch7x7_1.bn.running_var", "module.Mixed_6c.branch7x7_1.bn.num_batches_tracked", "module.Mixed_6c.branch7x7_2.conv.weight", "module.Mixed_6c.branch7x7_2.bn.weight", "module.Mixed_6c.branch7x7_2.bn.bias", "module.Mixed_6c.branch7x7_2.bn.running_mean", "module.Mixed_6c.branch7x7_2.bn.running_var", "module.Mixed_6c.branch7x7_2.bn.num_batches_tracked", "module.Mixed_6c.branch7x7_3.conv.weight", "module.Mixed_6c.branch7x7_3.bn.weight", "module.Mixed_6c.branch7x7_3.bn.bias", "module.Mixed_6c.branch7x7_3.bn.running_mean", "module.Mixed_6c.branch7x7_3.bn.running_var", "module.Mixed_6c.branch7x7_3.bn.num_batches_tracked", "module.Mixed_6c.branch7x7dbl_1.conv.weight", "module.Mixed_6c.branch7x7dbl_1.bn.weight", "module.Mixed_6c.branch7x7dbl_1.bn.bias", "module.Mixed_6c.branch7x7dbl_1.bn.running_mean", "module.Mixed_6c.branch7x7dbl_1.bn.running_var", "module.Mixed_6c.branch7x7dbl_1.bn.num_batches_tracked", "module.Mixed_6c.branch7x7dbl_2.conv.weight", "module.Mixed_6c.branch7x7dbl_2.bn.weight", "module.Mixed_6c.branch7x7dbl_2.bn.bias", "module.Mixed_6c.branch7x7dbl_2.bn.running_mean", "module.Mixed_6c.branch7x7dbl_2.bn.running_var", "module.Mixed_6c.branch7x7dbl_2.bn.num_batches_tracked", "module.Mixed_6c.branch7x7dbl_3.conv.weight", "module.Mixed_6c.branch7x7dbl_3.bn.weight", "module.Mixed_6c.branch7x7dbl_3.bn.bias", "module.Mixed_6c.branch7x7dbl_3.bn.running_mean", "module.Mixed_6c.branch7x7dbl_3.bn.running_var", "module.Mixed_6c.branch7x7dbl_3.bn.num_batches_tracked", "module.Mixed_6c.branch7x7dbl_4.conv.weight", "module.Mixed_6c.branch7x7dbl_4.bn.weight", "module.Mixed_6c.branch7x7dbl_4.bn.bias", "module.Mixed_6c.branch7x7dbl_4.bn.running_mean", "", ". 
</code></pre>
<pre><code class="lang-auto">def test():
    ##
    engine = Engine()
    config = getConfig()
    data_config = getDatasetConfig(config.dataset)
    # define dataset
    transform_test = transforms.Compose([
        transforms.Resize((config.image_size, config.image_size)),
        transforms.CenterCrop(config.input_size),
        transforms.ToTensor(),
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
    ])
    val_dataset = CustomDataset(
        data_config['val'], data_config['val_root'], transform=transform_test)
    val_loader = DataLoader(
        val_dataset, batch_size=config.batch_size, shuffle=False, num_workers=config.workers, pin_memory=True)
    # define model
    if config.model_name == 'inception':
        net = inception_v3_bap(pretrained=True, aux_logits=False)
    elif config.model_name == 'resnet50':
        net = resnet50(pretrained=True)

    in_features = net.fc_new.in_features
    new_linear = torch.nn.Linear(
        in_features=in_features, out_features=val_dataset.num_classes)
    net.fc_new = new_linear

    # load checkpoint
    use_gpu = torch.cuda.is_available() and config.use_gpu
    if use_gpu:
        net = net.cuda()
    gpu_ids = [int(r) for r in config.gpu_ids.split(',')]
    if use_gpu and len(gpu_ids) &gt; 1:
        net = torch.nn.DataParallel(net, device_ids=gpu_ids)
    #checkpoint_path = os.path.join(config.checkpoint_path,'model_best.pth.tar')
    net.load_state_dict(torch.load(config.checkpoint_path)['state_dict'])

    # define loss
    # define loss
    criterion = torch.nn.CrossEntropyLoss()
    if use_gpu:
        criterion = criterion.cuda()
    prec1, prec5 = engine.test(val_loader, net, criterion)
</code></pre>
<p>Can anyone help me please?</p>

ptrblck: <p>This error will be raised, if you’ve stored the <code>state_dict</code> from the <code>nn.DataParallel</code> model and are now trying to load it to a plain model.<br>
You could use <a href="https://discuss.pytorch.org/t/chexnet-code-error-runtimeerror-error-s-in-loading-state-dict-for-dataparallel-missing-key-s-in-state-dict-module-densenet121-features-conv0-weight/43790/3">this approach</a> to remove the <code>.module</code> from the keys or alternatively store the <code>state_dict</code> via:</p>
<pre><code class="lang-python">sd = model.module.state_dict()
torch.save(sd, PATH)
</code></pre>

Saifeddine_Barkia: <p>Thank you sir, it solved the problem, I’m trying another thing here, and I failed to fine-tune the model. It’s my first time doing that. It will take ages, if I’m going to run the model from the begining espacially it’s not the dataset that I will work on, I just want to test if it works properly. I will apperciate if you take a look on this one : <a href="https://discuss.pytorch.org/t/fine-tuning-a-resnet-model/90386" class="inline-onebox">Fine Tuning a Resnet Model</a> . Thank you.</p>