C1W1 UNQ_C6 get_disc_loss Assertion error

Hi,
I am having an assertion error in function get_disc_loss.

I have followed all the steps as described in the notebook. The error snippet is as follows:

AssertionError Traceback (most recent call last)
Input In [17], in <cell line: 73>()
70 if num_steps >= max_tests:
71 break
—> 73 test_disc_reasonable()
74 test_disc_loss()
75 print(“Success!”)

Input In [17], in test_disc_reasonable(num_images)
12 real = torch.ones(num_images, z_dim)
13 disc_loss = get_disc_loss(gen, disc, criterion, real, num_images, z_dim, ‘cpu’)
—> 14 assert torch.all(torch.abs(disc_loss.mean() - 0.5) < 1e-5)
16 gen = torch.ones_like
17 criterion = torch.mul # Multiply

AssertionError:

Unfortunately, there’s not much information to diagnose this. I’ve also tried refreshing the notebook as suggested in Assertion error in get_disc_loss C1W1 - #6 by Hitarth_Bhatt , but no luck :frowning:

I have passed the tests for 1-5 and 7th function but only for the 6th function, I have received this error causing me to fail the submission,.

Note that is the very first test of the get_disc_loss function, so something must be fundamentally wrong with your algorithm. I added some print statements in my get_disc_loss code and here’s what I get from that particular test:

fakes.shape torch.Size([10, 64])
fake_pred.shape torch.Size([10, 1])
fake_loss.shape torch.Size([10, 1])
real_loss.shape torch.Size([10, 1])
fake_loss tensor([[0.],
        [0.],
        [0.],
        [0.],
        [0.],
        [0.],
        [0.],
        [0.],
        [0.],
        [0.]])
real_loss tensor([[1.],
        [1.],
        [1.],
        [1.],
        [1.],
        [1.],
        [1.],
        [1.],
        [1.],
        [1.]])
disc_loss tensor([[0.5000],
        [0.5000],
        [0.5000],
        [0.5000],
        [0.5000],
        [0.5000],
        [0.5000],
        [0.5000],
        [0.5000],
        [0.5000]])

The tests here are pretty cleverly written and take maximum advantage of the fact that we are passing functions as arguments to get_disc_loss. Note what they use for the gen and disc functions for example.

Thank you. These outputs were helpful :slight_smile:

My final disc_loss was incorrect (a tensor of zeros) but fixed that now.