Week 1 Assignment 2 - HappyModel

Hi, I am new to TensorFlow and have some questions.

  1. What’s the difference between
    model = tf.keras.Sequential( [tfl…])

and

model = tf.keras.Sequential()
model.add(tfl…) …

I have some codes that work in the latter setting but not the former.

  1. For zero padding, can I use the following code
    tfl.ZeroPadding2D((?,?), input_shape=(?))
    something like that? Questions marks were used to respect the honor code.

  2. I got the following error message: File “”, line 38
    tfl.Conv2D(32, kernel_size=(7, 7), strides=1)
    ^
    SyntaxError: invalid syntax

What’s wrong here?

If you use the first syntax, then you are writing a list of layer instantiations, right? So you need a comma after every entry in order to create the list. That is the syntax for a python list. But if you use the “add()” method instead, then you can dispense with the commas.

1 Like