2 second Assignment week 1 : convolution application model

Happy model

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

thanks

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?

Thanks Paul Yes i did. corrected it , still getting error. Is the syntax i used in the first 2 line correct.

{moderator edit - solution code removed}

error
File “”, line 37
model.add(Conv2D(32,(7,7),1))

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.

Yes, i did . okay did modify the code getting the following error

{moderator edit - solution code removed}

 and getting the following error

File “”, line 59
return model
^
SyntaxError: invalid syntax

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

the above code got this error
File “”, line 58
return model
^
SyntaxError: invalid syntax

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.

Followed all the steps, twice including log out. still having the same copy, it did not over write it,

        tf.keras.layers.Dense(1, activation='sigmoid'),
        # YOUR CODE ENDS HERE


        return model

File “”, line 58
return model
^
SyntaxError: invalid syntax

Unless you can update it at you end

@hardevgill11
It looks like you are just missing a couple of parenthesis, that are part of the template and it somehow got erased for you.

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