"unexpected key in source state_dict:" "missing keys in source state_dict:" in training latest version of Swin Transdormer #2509
Description
Checklist
- I have searched related issues but cannot get the expected help.
- The bug has not been fixed in the latest version.
Describe the bug
unexpected key in source state_dict: norm.weight, norm.bias, stages.0.blocks.1.attn_mask, stages.1.blocks.1.attn_mask, stages.2.blocks.1.attn_mask, stages.2.blocks.3.attn_mask, stages.2.blocks.5.attn_mask, stages.2.blocks.7.attn_mask, stages.2.blocks.9.attn_mask, stages.2.blocks.11.attn_mask, stages.2.blocks.13.attn_mask, stages.2.blocks.15.attn_mask, stages.2.blocks.17.attn_mask
missing keys in source state_dict: norm0.weight, norm0.bias, norm1.weight, norm1.bias, norm2.weight, norm2.bias, norm3.weight, norm3.bias
Reproduction
- What command or script did you run?
checkpoint_file = './configs/swin/swin_large_patch4_window7_224_22k_20220412-aeecf2aa.pth'
model = dict(
backbone=dict(
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
pretrain_img_size=224,
embed_dims=192,
depths=[2, 2, 18, 2],
num_heads=[6, 12, 24, 48],
window_size=7),
decode_head=dict(in_channels=[192, 384, 768, 1536], num_classes=4),
auxiliary_head=dict(in_channels=768, num_classes=4))
- Did you make any modifications on the code or config?
No,
Did you understand what you have modified?
Yes.
- What dataset did you use?
custom dataset
Environment
-
Please run
python mmseg/utils/collect_env.py
to collect necessary environment information and paste it here.
It is not an environment issue. -
You may add addition that may be helpful for locating the problem, such as
- How you installed PyTorch [e.g., pip, conda, source]
- Other environment variables that may be related (such as
$PATH
,$LD_LIBRARY_PATH
,$PYTHONPATH
, etc.)
swin_large_patch4_window7_224_22k_20220412-aeecf2aa.pth'
Error traceback
2023-01-24 21:52:00,656 - mmseg - INFO - Set random seed to 1239451960, deterministic: False
/githubs/mmsegmentation/mmseg/models/losses/cross_entropy_loss.py:235: UserWarning: Default ``avg_non_ignore`` is False, if you would like to ignore the certain label and average loss over non-ignore labels, which is the same with PyTorch official cross_entropy, set ``avg_non_ignore=True``.
warnings.warn(
2023-01-24 21:52:02,174 - mmseg - INFO - load checkpoint from local path: ./configs/swin/swin_large_patch4_window7_224_22k_20220412-aeecf2aa.pth
2023-01-24 21:52:02,643 - mmseg - WARNING - The model and loaded state dict do not match exactly
unexpected key in source state_dict: norm.weight, norm.bias, stages.0.blocks.1.attn_mask, stages.1.blocks.1.attn_mask, stages.2.blocks.1.attn_mask, stages.2.blocks.3.attn_mask, stages.2.blocks.5.attn_mask, stages.2.blocks.7.attn_mask, stages.2.blocks.9.attn_mask, stages.2.blocks.11.attn_mask, stages.2.blocks.13.attn_mask, stages.2.blocks.15.attn_mask, stages.2.blocks.17.attn_mask
missing keys in source state_dict: norm0.weight, norm0.bias, norm1.weight, norm1.bias, norm2.weight, norm2.bias, norm3.weight, norm3.bias
2023-01-24 21:52:02,700 - mmcv - INFO - initialize UPerHead with init_cfg {'type': 'Normal', 'std': 0.01, 'override': {'name': 'conv_seg'}}
2023-01-24 21:52:02,833 - mmcv - INFO - initialize FCNHead with init_cfg {'type': 'Normal', 'std': 0.01, 'override': {'name': 'conv_seg'}}
2023-01-24 21:52:02,834 - mmcv - INFO -
Any help is appreciated.