ValueError: Target size (torch.Size([4, 1])) must be the same as input size (torch.Size([16, 1]))

Please read here:

https://pytorch.org/docs/stable/notes/autograd.html#in-place-operations-with-autograd

And if you’re not clear what an “in-place operation” is, read here first:

https://discuss.pytorch.org/t/what-is-in-place-operation

1 Like