Open aiqiangbrave opened 2 years ago
Check the size of the matrix/vector in x[0], if it has a 1 in the batch dimension, after squeeze in norm() function, this reduces to a vector which is problematic for the norm
Yes @aiqiangbrave
It is due to the batch size = 1
You could use
if len(x.shape) ==2:
x = x.unsqueeze(0)
Something like that.
okok,thank you for your reply.
---- 回复的原邮件 ---- | 发件人 | Zhedong @.> | | 日期 | 2022年04月20日 22:57 | | 收件人 | @.> | | 抄送至 | @.**@.> | | 主题 | Re: [NVlabs/DG-Net] IndexError:Dimension out of range(excepted to be in range of [-1,0],but got 1) (Issue #75) |
Yes @aiqiangbrave
It is due to the batch size = 1
You could use
x = x.unsqueeze(0)
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Check the size of the matrix/vector in x[0], if it has a 1 in the batch dimension, after squeeze in norm() function, this reduces to a vector which is problematic for the norm
okok,thank you!
Hello,can you help me ?thank you! When I use Market data set ,report an error:
problem: /home/waq/anaconda3/envs/re_person/bin/python /home/waq/Downloads/ai/re_person/code/DG-Net/DG-Net-master/test_2label.py -------test----------- /home/waq/Downloads/ai/re_person/code/DG-Net/DG-Net-master/test_2label.py:182: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. config = yaml.load(stream) Traceback (most recent call last): File "/home/waq/Downloads/ai/re_person/code/DG-Net/DG-Net-master/test_2label.py", line 204, in
gallery_feature = extract_feature(model,dataloaders['gallery'])
File "/home/waq/Downloads/ai/re_person/code/DG-Net/DG-Net-master/test_2label.py", line 131, in extract_feature
x[0] = norm(x[0])
File "/home/waq/Downloads/ai/re_person/code/DG-Net/DG-Net-master/test_2label.py", line 109, in norm
fnorm = torch.norm(f, p=2, dim=1, keepdim=True)
File "/home/waq/anaconda3/envs/re_person/lib/python3.6/site-packages/torch/functional.py", line 1337, in norm
return _VF.norm(input, p, _dim, keepdim=keepdim) # type: ignore
IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
Process finished with exit code 1
Thank you!