AbnerHqC / GaitSet

A flexible, effective and fast cross-view gait recognition network
582 stars 170 forks source link

运行train.py 总是会有这样的错误,不知道该怎么解决? #137

Open 15229671718 opened 3 years ago

15229671718 commented 3 years ago

D:\Python_Demo\GaitSet-master\model\network\triplet.py:22: UserWarning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead. (Triggered internally at ..\aten\src\ATen/native/IndexingUtils.h:20.) hard_hp_dist = torch.max(torch.masked_select(dist, hp_mask).view(n, m, -1), 2)[0] D:\Python_Demo\GaitSet-master\model\network\triplet.py:23: UserWarning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead. (Triggered internally at ..\aten\src\ATen/native/IndexingUtils.h:20.) hard_hn_dist = torch.min(torch.masked_select(dist, hn_mask).view(n, m, -1), 2)[0] Traceback (most recent call last): File "D:/Python_Demo/GaitSet-master/train.py", line 21, in m.fit() File "D:\Python_Demo\GaitSet-master\model\model.py", line 167, in fit ) = self.triplet_loss(triplet_feature, triplet_label) File "C:\Users\87615\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 722, in _call_impl result = self.forward(*input, kwargs) File "C:\Users\87615\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\parallel\data_parallel.py", line 153, in forward return self.module(*inputs[0], *kwargs[0]) File "C:\Users\87615\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 722, in _call_impl result = self.forward(input, kwargs) File "D:\Python_Demo\GaitSet-master\model\network\triplet.py", line 23, in forward hard_hn_dist = torch.min(torch.masked_select(dist, hn_mask).view(n, m, -1), 2)[0] RuntimeError: cannot perform reduction function min on tensor with no elements because the operation does not have an identity

Process finished with exit code 1

ShenChuanfu commented 3 years ago

The same problem. Fixed it by changing every

    hp_mask = (label.unsqueeze(1) == label.unsqueeze(2)).byte().view(-1) 
    hn_mask = (label.unsqueeze(1) != label.unsqueeze(2)).byte().view(-1)

to

    hp_mask = (label.unsqueeze(1) == label.unsqueeze(2)).bool().view(-1)
    hn_mask = (label.unsqueeze(1) != label.unsqueeze(2)).bool().view(-1)

in files: model\network\triplet.py

it caused by version conflict of pytorch

immanh commented 1 year ago

But it remains an error: "hard_hn_dist = torch.min(torch.masked_select(dist, hn_mask).view(n, m, -1), 2)[0] RuntimeError: cannot perform reduction function min on tensor with no elements because the operation does not have an identity

Process finished with exit code 1" How do you fix it?