Course 4, Week 1, Assignment 2, Conv2D

Hi Everyone,

I am stuck at def happyModel():

First two lines of my code are:

model = tf.keras.Sequential([
        ## ZeroPadding2D with padding 3, input shape of 64 x 64 x 3
        tfl.ZeroPadding2D(padding = 3, input_shape = (64, 64, 3) )
        
        ## Conv2D with 32 7x7 filters and stride of 1
        tfl.Conv2D(filters=32,kernel_size=(7,7),strides=(1, 1))

Testing this block results in:

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

I am not familiar with TensorFlow yet, but how can I solve this syntax error?

Thanks,
Ray

Ah, I realized I missed a comma after each line… Now I can keep going.

Right! That’s required with the Sequential Model, since what we’re doing here is creating a list (that’s a python data structure) of layers.

Please note that when we get to the Functional Model in the second part of this assignment, you don’t need commas and in fact they will backfire on you in a nasty way.

1 Like