Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

尝试复现MSMT17 vit_base 结果时,遇到报错: RuntimeError: The size of tensor a (751) must match the size of tensor b (1041) at non-singleton dimension 0 #78

Closed
superTongTong opened this issue Aug 2, 2023 · 1 comment

Comments

@superTongTong
Copy link

您好!当我尝试复现MSMT17的结果遇到问题。下面是我尝试的命令:
python test.py --config_file configs/MSMT17/vit_base.yml MODEL.DEVICE_ID "('0')" TEST.WEIGHT 'vit_base_msmt.pth

遇到了报错:

File "D:\yao_pytorch\TransReID-main\model\make_model.py", line 206, in load_param
    self.state_dict()[i.replace('module.', '')].copy_(param_dict[i])
RuntimeError: The size of tensor a (751) must match the size of tensor b (1041) at non-singleton dimension 0

之后我尝试在 make_model.py 添加 print(i, self.state_dict()[i.replace('module.', '')].shape, param_dict[i].shape) 得到如下结果:

base.norm.weight torch.Size([768]) torch.Size([768])
base.norm.bias torch.Size([768]) torch.Size([768])
base.fc.weight torch.Size([1000, 768]) torch.Size([1000, 768])
base.fc.bias torch.Size([1000]) torch.Size([1000])
classifier.weight torch.Size([751, 768]) torch.Size([1041, 768])
Traceback (most recent call last):
File "D:\yao_pytorch\TransReID-main\test.py", line 46, in <module>
model.load_param(cfg.TEST.WEIGHT)
File "D:\yao_pytorch\TransReID-main\model\make_model.py", line 206, in load_param
self.state_dict()[i.replace('module.', '')].copy_(param_dict[i])
RuntimeError: The size of tensor a (751) must match the size of tensor b (1041) at non-singleton dimension 0

求教如何解决? 非常感谢。

@kp97524
Copy link

kp97524 commented Nov 14, 2023

Hi @superTongTong ,

Did you figure out the fix for this issue? Am facing the same issue and there's no update for a while :(

Github issue: #70

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants