NVlabs / DG-Net

:couple: Joint Discriminative and Generative Learning for Person Re-identification. CVPR'19 (Oral) :couple:
https://www.zdzheng.xyz/publication/Joint-di2019
Other
1.27k stars 230 forks source link

size mismatch #31

Closed ghost closed 4 years ago

ghost commented 4 years ago

Thank you for your code. I try to use MSMT and cuhk03 to train this model, but when I try to enter 'python train.py --config configs/latest.yaml' , command line output an error: ‘size mismatch for classifier.classifier.0.bias: copying a param with shape torch.Size([751]) from checkpoint, the shape in current model is torch.Size([2559]).' I have found out that I must change the param in latest-fp16.yaml and config.yaml(I think config.yaml may be useless in this issue). And I have found out that this error is from /models/best/net_last.pth. The input kinds isn't suitable for this net. Do you have any solution to this or should I change the file? @layumi

ghost commented 4 years ago

I try to use Market, MSMT and cuhk03 dataset to train this model, so 2559 is the sum of these training kinds.

layumi commented 4 years ago

Hi @869250498 751 is the number of training classes in the Market dataset. You need to modify the number for MSMT and CUHK03 in the config file. https://github.com/NVlabs/DG-Net/blob/master/configs/latest.yaml#L6

ghost commented 4 years ago

Thank you for your reply @layumi I have done that. But it doesn't work. I have used 'print' to find out that the ID_class of the config of ‘DGNet_Trainer’ is 2559. I hold the view that this error is caused from mismatch of network and input classes.

layumi commented 4 years ago

Have you re-trained the teacher model? The default teacher model is for Market-1501 (which contains 751 classes)

ghost commented 4 years ago

Yes I want to re-trained this model. Or is there any other train way? By the project Person_reID_baseline_pytorch?

layumi commented 4 years ago

You could use the baseline to train a basic model, and then use it as the new teacher model.

ghost commented 4 years ago

Thank you for your reply. It works