Happy_model syntax

I’m not sure why I’m getting this error but when I’m trying to implement the happy_model function it’s telling me:

model.add(tfl.Conv2D(32, 7, strides = (1,1)))
^
SyntaxError: invalid syntax

It’s also giving me the error:

UnboundLocalError: local variable ‘model’ referenced before assignment

I’ve read through some of the documentation for keras and I guess I need to set the “model” object equal to something but is that not what the “model = tf.keras.Sequential([” does?

If you read the docs you may find that Sequential needs a list of layers as an argument. The code template already opens up the list for you, you just need to fill in the layer objects!

Are you saying that I need to tell the model the shape of the input? In the docs the examples have: model.add(keras.Input(shape=(250, 250, 3))) # 250x250 RGB images

Is this what I’m missing?

I won‘t solve it for you completely. But here is an example of how to setup a small Sequential:

tf.keras.Sequential([ tfl.Conv2D(filters=5,kernel_size=3,…), tfl.Flatten(),…])

This only two layers. Hope this helps!

You have to feed your model parameters as you feed a list .
PS : you should use ‘,’

1 Like

I am now getting an error that says “init() got multiple values for argument ‘padding’”
This is what I have for the ZeroPadding2D function:

tfl.ZeroPadding2D(padding = 3, (64,64,3)),

Ok I have changed it so that it is now:

tf.keras.Input(shape = (64,64,3))
til.ZeroPadding2D(padding = 3)

and I am getting the error: Input 0 of layer zero_padding2d_5 is incompatible with the layer: expected ndim=4, found ndim=0. Full shape received: