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

error oim_loss.py #17

Closed pribadihcr closed 7 years ago

pribadihcr commented 7 years ago

Hi @Cysu,

When run

open-reid$ python examples/oim_loss.py -d viper -b 64 -j 2 -a resnet50 --logs-dir logs/oim-loss/viper-resnet50

I got the following error: Files already downloaded and verified VIPeR dataset loaded

subset | # ids | # images train | 216 | 432 val | 100 | 200 trainval | 316 | 632 query | 316 | 632 gallery | 316 | 632 Traceback (most recent call last): File "examples/oim_loss.py", line 222, in main(parser.parse_args()) File "examples/oim_loss.py", line 151, 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 70, in _forward outputs = self.model(inputs) File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 224, in call result = self.forward(input, kwargs) File "/usr/local/lib/python2.7/dist-packages/torch/nn/parallel/data_parallel.py", line 58, in forward return self.module(*inputs[0], *kwargs[0]) File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 224, in call result = self.forward(input, kwargs) File "/home/deep307/PROJECT/open-reid/reid/models/resnet.py", line 81, in forward x = x / x.norm(2, 1).expand_as(x) File "/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.py", line 725, in expand_as return Expand.apply(self, (tensor.size(),)) File "/usr/local/lib/python2.7/dist-packages/torch/autograd/_functions/tensor.py", line 111, in forward result = i.expand(*new_size) RuntimeError: The expanded size of the tensor (128) must match the existing size (64) at non-singleton dimension 1. at /pytorch/torch/lib/THC/generic/THCTensor.c:323

Cysu commented 7 years ago

@pribadihcr Pytorch changes a bit in v0.2. A quick workaround is changing this line to

x = x / x.norm(2, 1, keepdim=True)

Same applies for the Inception Net here.