fxia22 / stn.pytorch

pytorch version of spatial transformer networks
Other
589 stars 87 forks source link

Runtime error: dimension out of range #22

Open kindlychung opened 6 years ago

kindlychung commented 6 years ago
python test.py 
Variable containing:
(0 ,.,.) = 
  0.8000  0.3000  1.0000
  0.5000  0.0000  0.0000
[torch.FloatTensor of size 1x2x3]

Traceback (most recent call last):
  File "test.py", line 28, in <module>
    out, aux = g(input)
  File "/home/kaiyin/miniconda3/envs/torch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 325, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/kaiyin/PycharmProjects/stn.pytorch/script/modules/gridgen.py", line 30, in forward
    loss = torch.sum(loss,2)
RuntimeError: dimension out of range (expected to be in range of [-2, 1], but got 2)

Pytorch version: 0.3.0.post4 Python 3.6

wanrenjie commented 6 years ago

I also find this problem. To solve this problem, I change the loss = torch.sum(loss,1), loss = torch.sum(loss,2) to loss = torch.sum(loss) directly. Is it right...