GaitSet icon indicating copy to clipboard operation
GaitSet copied to clipboard

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

Open 15229671718 opened this issue 3 years ago • 2 comments

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

15229671718 avatar Mar 24 '21 06:03 15229671718

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

ShenChuanfu avatar May 01 '21 16:05 ShenChuanfu

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?

immanh avatar May 08 '23 00:05 immanh