ZeroPadding2D & input help

I’m working on the keras sequential model and the assignment is asking to do ZeroPadding2D with an input size of (64,64,3). I don’t understand how I’m supposed to be specifying the input inside the ZeroPadding2D, or if I should be doing that on another line. Could someone explain? The API uses this as an example and I don’t understand it:

“input_shape = (64,64,3)” is an argument to the ZeroPadding2D() layer.


When I specify the second argument like this tfl.ZeroPadding2D(padding=(3, 3),input_shape=(64,64,3)) , I get the following error:

Most likely that means there is something wrong on the previous line. E.g. that you forgot to terminate it with a comma. That is not necessary in python in general, but you are defining a list of functions here. That is how the Sequential API works.

They don’t give us much guidance on the Sequential and Functional APIs here and the documentation is pretty rough going as well. Here is a thread from ai_curious which is probably the best way to get a handle on how to use these two Keras APIs.

You have a syntax error, probably mismatched parenthesis, or something like that. It could be in another line of code and the error is detected on Conv2D().

Thank you! (which in itself is not large enough to post, so I added this)

Thank you! Can you briefly explain the reason of the error caused by the lack of input_shape definition?

ZeroPadding2D() inherits from Layer(), which provides this information:


Thanks for your help!