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

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

Closed
giuliasilvestro opened this issue May 23, 2019 · 4 comments

Comments

@giuliasilvestro
Copy link

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

olivier-gillet commented May 28, 2019

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

giuliasilvestro commented Jun 3, 2019

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

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

Thanks! that worked.

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

2 participants