Please could you tell about doing it on nn.BCEWithLogitsLoss()
def real_loss(D_out):
   labels = torch.ones(D_out.size(0)) * 0.9 #smoothing by default
    criterion = nn.BCEWithLogitsLoss()
    if train_on_gpu:
        labels = labels.cuda()
    loss = criterion(D_out.squeeze(), labels)
    return loss

It is giving error
ValueError: Target size (torch.Size([32])) must be the same as input size (torch.Size([32, 4096]))
But i tried to debug it, printed results and found that error were coming from using criterion(D_out.squeeze(), labels)
I printed out  shape of D_out found that torch.Size([32, 4096])
I hit trialed any  possible combination to accept criterion but it throws  same error.
Please could you give me any idea why this kind of error is occuring in my code?
Thank you for helping us