Help with DLS 4 week1 assignment 2

I am having some difficulty understanding and figuring out the
HappyModel() sequential model within the
tf.keras.Sequential() construct ?

I think I have done it right but am getting an error for the last Dense layer.

Final message says -
TypeError: The added layer must be an instance of class Layer. Found: Tensor(“zero_padding2d_9/Pad:0”, shape=(None, 70, 70, 3), dtype=float32)

I am also having some trouble implementing the ReLU activations in part 2 - hand signs

I have tried a syntax of
A1 = tfl.ReLU(Z1) or A1 = tfl.ReLU()(Z1) and am getting some errors.

Any help is appreciated.

1 Like

Neither of those is correct. In the “Sequential” model case, we just want to define the layer function by calling it, but not then to call the function that gets returned. I know this is a bit confusing and they don’t really give much explanation. But the point is that just saying tfl.ReLU() calls the layer function and it returns the function that you want to add to the sequential list. You don’t actually pass it an argument or save the return value: the return value is the function itself. When we get to the “Functional Model” it will be a completely different situation and your second formula is the correct one.