There should be no large difference between nn.BCELoss() and nn.BCEWithLogitsLoss(), but how about trying to replace nn.BCEWithLogitsLoss() in your code with nn.BCELoss()? The PyTorch DCGAN example use nn.BCELoss(), but presumably its use is just for simplicity.