Closed pribadihcr closed 7 years ago
@pribadihcr What's the version of your pytorch?
@pribadihcr 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())
HI @Cysu
yes, I am using v0.2. And also we need to change loss/triplet.py in line 26 with dist_an.append(dist[i][1 + (-1)*mask[i]].min()) to get triplet_loss.py working.
Hi @Cysu
I got triplet_loss error:
open-reid$ python examples/triplet_loss.py -d cuhk03 -b 64 -j 2 -a resnet50 --logs-dir logs/triplet-loss/cuhk03-resnet50 Files already downloaded and verified CUHK03 dataset loaded subset | # ids | # images train | 1267 | 24345 val | 100 | 1918 trainval | 1367 | 26263 query | 100 | 1930 gallery | 100 | 1930 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 "open-reid/reid/trainers.py", line 31, in train
loss, prec1 = self._forward(inputs, targets)
File "open-reid/reid/trainers.py", line 80, in _forward
loss, prec = self.criterion(outputs, targets)
File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 224, in call
result = self.forward(*input, **kwargs)
File "open-reid/reid/loss/triplet.py", line 26, in forward
dist_an.append(dist[i][1 - mask[i]].min())
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'