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

Using a target size (torch.Size([64])) that is different to the input size (torch.Size([64, 1]) #9

Open
bajixing opened this issue Apr 11, 2022 · 1 comment

Comments

@bajixing
Copy link

loss = F.binary_cross_entropy(y_pred, y)

Hello,
First I got a ValueError: Using a target size (torch.Size([64])) that is different to the input size (torch.Size([64, 1])) is deprecated. Please ensure they have the same size.
Then I altered y_pred to y_pred.squeeze().detach(), but I got a new error showing element 0 of tensors does not require grad and does not have a grad_fn where in line 93, loss.backward().
So can you help me? what should I do?

@NivNagli
Copy link

@bajixing Add at main.py after line 85 the next code line : y = y.unsqueeze(1), will solve out the problem for you.

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