aitorzip / PyTorch-CycleGAN

A clean and readable Pytorch implementation of CycleGAN
https://arxiv.org/abs/1703.10593
GNU General Public License v3.0
1.19k stars 283 forks source link

UserWarning: using a target size (torch.Size([1])) that is different to input size (torch.Size([1],[1])) #15

Closed giuliasilvestro closed 5 years ago

giuliasilvestro commented 5 years ago

"This wil likely lead to incorrect results due to broadcasting. Please ensure they have the same size"

Does anybody know how to fix this issue?

olivier-gillet commented 5 years ago

I think it's due to pytorch version (I use pytorch 1.1.0) -> just remove the '-1' in the return of the forward function in models.py. It is just a question of shape. return F.avg_pool2d(x, x.size()[2:]).view(x.size()[0])

giuliasilvestro commented 5 years ago

Thanks! that worked for the training. However I get this error whe I execut ./test

File "./test", line 71, in <module>

real_A = Variable(input_A.copy_(batch['A']))

RuntimeError: The expanded size of the tensor (256) must match the existing size (400) at non-singleton dimension 3.  Target sizes: [1, 3, 256, 256].  Tensor sizes: [1, 3, 400, 400]
olivier-gillet commented 5 years ago

It seems to be just a size issue. Are you testing the model on 400x400 images? If it is the case you need to run : ./test --size 400

giuliasilvestro commented 5 years ago

Thanks! that worked.