Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error oim_loss.py #17

Closed
pribadihcr opened this issue Aug 11, 2017 · 1 comment · Fixed by #20
Closed

error oim_loss.py #17

pribadihcr opened this issue Aug 11, 2017 · 1 comment · Fixed by #20

Comments

@pribadihcr
Copy link

pribadihcr commented Aug 11, 2017

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
Copy link
Owner

Cysu commented Aug 13, 2017

@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.

@Cysu Cysu mentioned this issue Aug 28, 2017
@Cysu Cysu closed this as completed in #20 Aug 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants