Skip to content

init_weight got a table_key Error #4

@ForeUP

Description

@ForeUP

I try to run swin_small model, and I have convert_model to teacher model, met an error like fllow:

using img_triplet sampler
using Transformer_type: swin_tiny_patch4_window7_224 as a backbone
/home/yoyo/G/Ubuntu/PythonProject/Transformer/SOLIDER-REID/model/backbones/swin_transformer.py:1159: UserWarning: DeprecationWarning: pretrained is deprecated, please use "init_cfg" instead
  warnings.warn('DeprecationWarning: pretrained is deprecated, '
Traceback (most recent call last):
  File "/home/yoyo/G/Ubuntu/Applications/pycharm-2022.3/plugins/python/helpers/pydev/pydevd.py", line 1496, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/yoyo/G/Ubuntu/Applications/pycharm-2022.3/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/yoyo/G/Ubuntu/PythonProject/Transformer/SOLIDER-REID/train.py", line 72, in <module>
    model = make_model(cfg, num_class=num_classes, camera_num=camera_num, view_num = view_num, semantic_weight = cfg.MODEL.SEMANTIC_WEIGHT)
  File "/home/yoyo/G/Ubuntu/PythonProject/Transformer/SOLIDER-REID/model/make_model.py", line 448, in make_model
    model = build_transformer(num_class, camera_num, view_num, cfg, __factory_T_type, semantic_weight)
  File "/home/yoyo/G/Ubuntu/PythonProject/Transformer/SOLIDER-REID/model/make_model.py", line 195, in __init__
    self.base.init_weights(model_path)
  File "/home/yoyo/G/Ubuntu/PythonProject/Transformer/SOLIDER-REID/model/backbones/swin_transformer.py", line 1344, in init_weights
    table_current = self.state_dict()[table_key]
KeyError: 'stages.2.blocks.6.attn.w_msa.relative_position_bias_table'

It may means that could not fund a dict key in self.state_dict(), and I found the table_key is obtain from the pretained model.
Should I change the source of table key to obrain the table_key from the SwinTransformer model itself or its just my error not the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions