Hi
First off am I in the right track , it says
TensorFlow Keras Sequential API can be used to build simple models with layer operations that proceed in a sequential order.
You can also add layers incrementally to a Sequential model with the .add() method
I am getting error , Please guide. Being trying different things, no advancing.
{moderator edit - solution code removed}
Error:
File “”, line 38
model.add(Conv2D(32,(7,7),1))
^
SyntaxError: invalid syntax
When you get a syntax error like that at the beginning of a line, that means there is something wrong with the previous line, which is the zero padding line.
My guess is that the mistake is that you misspelled the name of the zero padding layer function. It’s ZeroPadding2D, right?
Have you read the documentation for tfl.Conv2D? Note that strides is a “named parameter” (aka “keyword argument”) in python, not a positional parameter.
Update: sorry, I think that’s not the problem. I wrote it the way you show and it worked for me. Are you sure you are showing the entire error message that you got?
Oh, ok, I think it’s that the parentheses don’t match on the ZeroPadding2D line: you have 4 open but only 3 close parens. That’s why you get the syntax error. That was ok the first time around, but must have gotten changed when you fixed the spelling.
Please ignore the upper message modified a few stuff
YOUR CODE STARTS HERE
## ZeroPadding2D with padding 3, input shape of 64 x 64 x4
tf.keras.layers.ZeroPadding2D(padding=(3,3),input_shape=(64,64,3)),
## Conv2D with 32 7x7 filters and stride of 1
tf.keras.layers.Conv2D(32, (7, 7), strides = (1, 1)),
# BatchNormalization for axis 3
tf.keras.layers.BatchNormalization(axis = 3),
## ReLU
tf.keras.layers.ReLU(),
## Max Pooling 2D with default parameters
tf.keras.layers.MaxPool2D(2, 2),
## Flatten layer
tf.keras.layers.Flatten(),
## Dense layer with 1 unit for output & 'sigmoid' activatio
tf.keras.layers.Dense(1, activation='sigmoid'),
# YOUR CODE ENDS HERE
return model
You evidently switched to using the “list” method, but you must have clobbered part of the template code when you were doing the “add()” method. You should get a clean copy of the notebook and compare what the template code looks like. (See the FAQ Thread for that.) There’s some more code required between the end of your list and the return statement.
Did you rename your notebook out of the way first? The instructions are pretty clear on that point. Or if getting a new notebook is just too much work, then try looking at how you initiated the Sequential call. What would it take to close that off at the end? It has to match in a symmetrical way, right?
Yes
paul i did rename, finally i add the extra extension , and yes it did upload the fresh one.
Should have know better to track the brackets, Its working the list method.
going to try the add method.
Learned a lot list vs the sequential add method.
thanks you very much