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

input and target shapes do not match: input [25 x 17 x 2 x 2], target [25 x 17] #30

Closed
AidasK opened this issue Aug 30, 2018 · 5 comments

Comments

@AidasK
Copy link

AidasK commented Aug 30, 2018

Any idea why this error occurs? I am using 224x224 celeba aligned database.

Traceback (most recent call last):
  File "train.py", line 141, in <module>
    Train()
  File "train.py", line 27, in __init__
    self._train()
  File "train.py", line 40, in _train
    self._train_epoch(i_epoch)
  File "train.py", line 69, in _train_epoch
    self._model.optimize_parameters(keep_data_for_visuals=do_visuals, train_generator=train_generator)
  File "/home/aidas/GANimation/models/ganimation.py", line 208, in optimize_parameters
    loss_D, fake_imgs_masked = self._forward_D()
  File "/home/aidas/GANimation/models/ganimation.py", line 281, in _forward_D
    self._loss_d_cond = self._criterion_D_cond(d_real_img_cond, self._real_cond) / self._B * self._opt.lambda_D_cond
  File "/root/miniconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/root/miniconda2/lib/python2.7/site-packages/torch/nn/modules/loss.py", line 421, in forward
    return F.mse_loss(input, target, reduction=self.reduction)
  File "/root/miniconda2/lib/python2.7/site-packages/torch/nn/functional.py", line 1716, in mse_loss
    return _pointwise_loss(lambda a, b: (a - b) ** 2, torch._C._nn.mse_loss, input, target, reduction)
  File "/root/miniconda2/lib/python2.7/site-packages/torch/nn/functional.py", line 1674, in _pointwise_loss
    return lambd_optimized(input, target, reduction)
RuntimeError: input and target shapes do not match: input [25 x 17 x 2 x 2], target [25 x 17] at /pytorch/aten/src/THCUNN/generic/MSECriterion.cu:12
@AidasK
Copy link
Author

AidasK commented Aug 30, 2018

I am using pytorch 0.4.1 and since this code is using Variables, it should have been written for pytorch 0.3.0. Can this be the case?

@AidasK
Copy link
Author

AidasK commented Aug 30, 2018

I went around this by using 128 size images.

@AidasK AidasK closed this as completed Aug 30, 2018
@jas0n1ee
Copy link

@AidasK are you still using aligned celebA dataset when doing resizing?

@AidasK
Copy link
Author

AidasK commented Oct 14, 2018

No, results were not good enough for me

@yangzhikai
Copy link

@AidasK INput image shuold be 128*128

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

No branches or pull requests

3 participants