Skip to content

在训练.npy文件时报错 #1

Description

@hurryup186

感谢作者提供了代码,但是在生成.npy文件时发生了报错“Resized position embedding from size:torch.Size([1, 129, 768]) to size: torch.Size([1, 193, 768]) with height:24 width: 8
Load 196 / 201 layers.
Traceback (most recent call last):
File "train_sysu_IRcam_impoved.py", line 874, in
main()
File "train_sysu_IRcam_impoved.py", line 450, in main
main_worker_stage2(args,log_s1_name,log_s2_name) # Stage 2
File "train_sysu_IRcam_impoved.py", line 626, in main_worker_stage2
model.load_state_dict(checkpoint['state_dict'])
File "/home/zyf/anaconda3/envs/RPNR/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1497, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for DataParallel:
Unexpected key(s) in state_dict: "module.bottlenecks.1.weight", "module.bottlenecks.1.bias", "module.bottlenecks.1.running_mean", "module.bottlenecks.1.running_var", "module.bottlenecks.1.num_batches_tracked", "module.bottlenecks.2.weight", "module.bottlenecks.2.bias", "module.bottlenecks.2.running_mean", "module.bottlenecks.2.running_var", "module.bottlenecks.2.num_batches_tracked", "module.bottlenecks.3.weight", "module.bottlenecks.3.bias", "module.bottlenecks.3.running_mean", "module.bottlenecks.3.running_var", "module.bottlenecks.3.num_batches_tracked".
size mismatch for module.cls_token: copying a param with shape torch.Size([1, 4, 768]) from checkpoint, the shape in current model is torch.Size([1, 1, 768]).
size mismatch for module.pos_embed: copying a param with shape torch.Size([1, 196, 768]) from checkpoint, the shape in current model is torch.Size([1, 193, 768]).”我们发现模型位置嵌入被调整为完全匹配24 x 8 + 1 = 193个位置(包括class token),但从主训练代码train_sysu.py得到sysu_s2保存的模型的应该是24 x 8 + 4 = 196(使用4个class tokens),我们想询问一下,是否是我们哪里设置的不对造成的吗?但我发现模型加载出现了报错

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions