Yes, exactly. Your target has the shape [1], while the output uses [1, 1], which will raise this warning. Just to make sure to avoid future issues, use label_real = label_real.unsqueeze(1) before passing it to criterion_GAN.


You have to push the model as well as all inputs to the right device. If you are using the GPU, you would thus have to transfer the data via x = x.to('cuda') or x = x.cuda(). To transfer it back, use x = x.to('cpu'). Variables are not needed anymore at all, neither for CUDA operations nor for CPU ops.


Yes, please post all code snippets and the outputs as formatted code, as it’s easier to debug and the forum search can index it. Pictures are not always easy to read, cannot be used to copy the source code for debugging, and the search won’t index it.