Person_reID_baseline_pytorch icon indicating copy to clipboard operation
Person_reID_baseline_pytorch copied to clipboard

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

Open wangzhiyuanking opened this issue 4 years ago • 1 comments

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 = load_network(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.

wangzhiyuanking avatar May 27 '20 00:05 wangzhiyuanking

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.

layumi avatar May 29 '20 12:05 layumi