Trouble defining the DCGAN discriminator block

In this week’s lab, I’m having trouble defining the DCGAN discriminator block as described in the instructions:

        #     Steps:
        #       1) Add a convolutional layer using the given parameters.
        #       2) Do a batchnorm, except for the last layer.
        #       3) Follow each batchnorm with a LeakyReLU activation with slope 0.2.
        #       Note: Don't use an activation on the final layer
        
        # Build the neural block
        if not final_layer:
            return nn.Sequential(
                #### START CODE HERE #### #
                nn.Conv2d(input_channels, output_channels, kernel_size, stride=stride),
                nn.BatchNorm2d(output_channels),
                nn.LeakyReLU(0.2)
                #### END CODE HERE ####
            )
        else: # Final Layer
            return nn.Sequential(
                #### START CODE HERE #### #
                nn.Conv2d(input_channels, output_channels, kernel_size, stride=stride)
                #### END CODE HERE ####
            )

Can someone point out where I went wrong? The instructions seemed very straightforward.

1 Like

Hello @Bradley_M_Messer,

Could you please explain the error you’re experiencing? Can you share the output of the discriminator block’s test cell?

Here’s the output:
image

Did you change anything in the UNQ_C4 ?

@shreyasvedpathak My apologies. I didn’t explain much thinking this was a very straightforward issue. What’s going on is that I’ve completed UNQ_C3 as shown above and it passes the unit tests as shown in UNQ_C4 (it has been a while because for efficiency sake, I move forward with future weeks while still debugging past weeks and then come back to it.).

@vkmavani3 Thanks for posting a response. I don’t think it is UNQ_C4 as I’m at least 90% sure that I didn’t modify anything in that cell (I’ve streamlined cells on future assignments to be able to understand what needed done and then had to fetch down a copy of the notebook as I’d done too much streamlining).

Removing this post - I found the careless mistake I made thanks to this poster’s suggestion AssertionError Test the hidden block