Hello,

In the first programming assignment in week1, we need to define the method “get_disc_loss” and compute the discriminator loss. I’m confused about how to calculate the discriminator loss.

The exercise instructions suggest to “Calculate the discriminator’s loss by averaging the real and fake loss and set it to disc_loss”

The real and fake loss are computed using the provided criterion and comparing the predictions to a “ground truth”, wich are zeros (fake) or ones (real). The result is a tensor with a loss for each image of the batch. Since disc_loss is a torch scalar, and the real and fake loss are tensors, I understand that the average of both can be computed in different ways.

```
noise_vect = ...
gen_images = ...
disc_preds_fake = disc(gen_images)
loss_fake = criterion(disc_preds_fake, ground truth for fakes)
disc_preds_real = disc(real)
loss_real = criterion(disc_preds_real, ground truth for reals)
disc_loss = (loss_fake+loss_real)/2
```

the code as I’m presenting above returns an error because it was expecting a torch scalar and disc_loss is a tensor:

“assert (disc_loss - 0.68).abs() < 0.05

RuntimeError: Boolean value of Tensor with more than one value is ambiguous”

I’ve also tried

disc_loss = (loss_fake+loss_real).mean()

But in this case i get blocked on the test_disc_reasonable test:

assert torch.all(torch.abs(disc_loss.mean() - 0.5) < 1e-5)

Can you help me understand how to compute the discriminator loss? What Could be missing?

Thank you