Closed YachaoDong closed 4 years ago
训练到这个步骤时候出错,网上查了也没查到有用的结果,希望得到解答!
Did you comment nn.DataParallel
?
Did you comment
nn.DataParallel
?
因为我只有一个GPU,所以没有用这个选项,如果是这个问题的话,我该怎样使用单个GPU训练?
单GPU也可以nn.DataParallel
,不需要注释掉。在script设置里CUDA_VISIBLE_DEVICES=0
。
单GPU也可以
nn.DataParallel
您好,刚训练了,可以跑起来了,预训练的的两个model没有使用nn.DataParallel,这个貌似应该对后面的训练测试应该没有影响?
有影响,你看log里是不是预训练模型没load进去。得把copy_state_dict
放到nn.DataParallel
前面去。
有影响,你看log里是不是预训练模型没load进去。得把
copy_state_dict
放到nn.DataParallel
前面去。
感谢回答!
请问训练过程中出现: mismatch: module.classifier.weight torch.Size([702, 2048]) torch.Size([500, 2048]) missing keys in state_dict: {'module.classifier.weight'} mismatch: module.classifier.weight torch.Size([702, 2048]) torch.Size([500, 2048]) missing keys in state_dict: {'module.classifier.weight'}
这个正常吗?从结果来看,我的单个GPU Batch_size为 64(16*4), 设置都没变,duke TO Market1501 res_ibn_a_50, 500类别的设置,测试精度为Mean AP: 74.6%, top-1 :89.4%,比原文中的测试结果少了一个点左右。 这是否与上面的 Missing...有关?或者有什么建议能达到最好的精度(论文中的精度)?期待您的回复! @yxgeee
Missing是因为预训练和MMT的类别数量不同,所以classifier的weight无法load,对性能不影响,是正常现象。少了一个点应该是因为GPU数量的问题,文章里的结果是4卡跑的,你这个是单卡,给BN的batchsize不同,所以最终结果有出入。
=> Loaded checkpoint 'logs/dukemtmcTOmarket1501/resnet_ibn50a-pretrain-1/model_best.pth.tar' mismatch: classifier.weight torch.Size([702, 2048]) torch.Size([500, 2048]) missing keys in state_dict: {'classifier.weight'} mismatch: classifier.weight torch.Size([702, 2048]) torch.Size([500, 2048]) missing keys in state_dict: {'classifier.weight'}
Traceback (most recent call last): File "examples/mmt_train_kmeans.py", line 272, in
main()
File "examples/mmt_train_kmeans.py", line 131, in main
main_worker(args)
File "examples/mmt_train_kmeans.py", line 149, in main_worker
model_1, model_2, model_1_ema, model_2_ema = create_model(args)
File "examples/mmt_train_kmeans.py", line 107, in create_model
model_1ema.module.classifier.weight.data.copy(model_1.module.classifier.weight.data)
File "/root/miniconda/envs/berttext/lib/python3.6/site-packages/torch/nn/modules/module.py", line 591, in getattr
type(self).name, name))
AttributeError: 'ResNetIBN' object has no attribute 'module'