layumi / Person_reID_baseline_pytorch

:bouncing_ball_person: Pytorch ReID: A tiny, friendly, strong pytorch implement of person re-id / vehicle re-id baseline. Tutorial 👉https://github.com/layumi/Person_reID_baseline_pytorch/tree/master/tutorial
https://www.zdzheng.xyz
MIT License
4.06k stars 1k forks source link

model.classifier.classifier = nn.Sequential ()? #212

Open wangzhiyuanking opened 4 years ago

wangzhiyuanking commented 4 years ago

Hello, what's in the test model.classifier.classifier = nn.Sequential () what effect does removal have on the results? Shouldn't the new classification layer be loaded when the model is loaded? I use the following code in train to load the PTH generated by the same network model, which will report an error,How can I modify the PTH generated by the same network if I want to load it in the train code: model = loadnetwork(model) model.classifier.classifier = nn.Sequential() model = model.cuda() error: RuntimeError: cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/generic/ THCTensorMath.cu:24 /pytorch/aten/src/THCUNN/ ClassNLLCriterion.cu:105 : void cunn ClassNLLCriterion updateOutput kernel(Dtype , Dtype , Dtype , long , Dtype *, int, int, int, int, long) [with Dtype = float, Acctype = float]: block: [0,0,0], thread: [10,0,0] Assertion t >= 0 &amp;&amp; t < n_ classes failed.

layumi commented 4 years ago

Hi @wangzhiyuanking While you use the model.classifier.classifier = nn.Sequential(), it removes the final linear classifier. Therefore, the model will output 512-dim feature. If you trained the model on Market (751 classes), the target label length 751 > feature length 512 will raise this error.