Cysu / open-reid

Open source person re-identification library in python
https://cysu.github.io/open-reid/
MIT License
1.34k stars 349 forks source link

**AttributeError: 'torch.cuda.ByteTensor' object has no attribute 'neg'** --- New issues along with the update of pytorch #19

Closed wangxiao5791509 closed 7 years ago

wangxiao5791509 commented 7 years ago

Hi, recently, the pytorch has updated and the code does not run smoothly in the new pytorch version. The following error occurs, could you please update a new version of the code ?

Traceback (most recent call last): File "examples/triplet_loss.py", line 217, in main(parser.parse_args()) File "examples/triplet_loss.py", line 145, in main trainer.train(epoch, train_loader, optimizer) File "build/bdist.linux-x86_64/egg/reid/trainers.py", line 31, in train File "build/bdist.linux-x86_64/egg/reid/trainers.py", line 80, in _forward File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 224, in call result = self.forward(*input, kwargs) File "build/bdist.linux-x86_64/egg/reid/loss/triplet.py", line 26, in forward File "/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.py", line 826, in rsub return SubConstant.apply(other, self) File "/usr/local/lib/python2.7/dist-packages/torch/autograd/_functions/basicops.py", line 130, in forward return tensor.neg().add(constant) AttributeError: 'torch.cuda.ByteTensor' object has no attribute 'neg'**

Cysu commented 7 years ago

@wangxiao5791509 Seems to be a bug in pytorch v0.2. A quick workaround is to change this line to

dist_an.append(dist[i][mask[i] == 0].min())

Also refers to #18.

wangxiao5791509 commented 7 years ago

@Cysu Thanks for your replay. It worked. However, I found one bug of your paper, after that. When testing, it show me the error: screenshot from 2017-08-15 17 09 51

I solved this issue using unsqueeze provided by pytorch ... screenshot from 2017-08-15 22 39 06

maybe you should check this ...

Cysu commented 7 years ago

@wangxiao5791509 Thank you very much for pointing out this issue! PyTorch changes the behavior quite a bit from v0.12 to v0.2. We will adapt our code base to v0.2 soon. Many thanks again.

wangxiao5791509 commented 7 years ago

@Cysu That's cool. Waiting for your update of this code. Here, I run the code and test it, the results is (triplet loss + resnet50 + market1501 + batchsize=64): screenshot from 2017-08-15 22 27 50

But the benchmark results is : screenshot from 2017-08-13 22 36 47

So, I wonder how can I achieve the performance as high as the benmark results ?? Waiting for your replay. Thank you very much .

Cysu commented 7 years ago

@wangxiao5791509 There is a command at the end of each row of the benchmark table. If you only have one GPU, may consider reducing the batch size and learning rate accordingly, please refer to this section.

Cysu commented 7 years ago

The original errors have been fixed in #20.