At a loss with get_disc_loss

I tried many variations but I am missing something. Here is my code. Any tips would be helpful. Thank you.

START CODE HERE

noise = get_noise(num_images, z_dim, device)
fimage = gen(noise)
pred = disc(fimage)
fake = torch.zeros_like(torch.empty(num_images, z_dim))
floss = criterion(pred, True)
yhat = criterion(pred, False)
disc_loss = torch.abs((yhat + floss)/2)
#### END CODE HERE ####

Hi @baysailor,

You are close! One key thing to keep in mind is that pred is the predictions for a batch of images, so the target parameter to criterion() needs to be a batch of target values, not just a single True or False. In other words, the second parameter to criterion() needs to be the same shape as the first one. torch.zeros_like() and torch.ones_like() are your friends here. They will ensure you have the same shape and also the same device.

With that hint, see if you can get it working. Once you have it, we should remove your code snippet from your post since sharing code is against community guidelines.