[week 1 Programming Assignment #2] ZeroPadding2D with padding 3, input shape of 64 x 64 x 3


I have a doubt regarding the last assignment of Week 1.

When defining the model, we are required to specify an input shape of 64 x 64 x 3.

However, it is unclear to me how to do this. Obviously, I have looked at the documentation (tf.keras.layers.ZeroPadding2D  |  TensorFlow Core v2.4.1) and Googled quite a bit, but would appreciate some pointer or some understanding of what is going on because I have been stuck here for the whole afternoon.

1 Like

Solved. For future reference: it goes as an argument inside the tfl.ZeroPadding2D function

1 Like

Hi vaccam1,

input_shape can be used as a parameter in ZeroPadding2D. Unfortunately this is not mentioned in the documentation.

I hope this brightens your afternoon!


Hi vaccam1,

Good to read you resolved the issue. Could you please remove your explicit piece of code?

Thanks and good luck with the rest of the course!

Done, thanks and take care

Hi @reinoudbosch, It will help me to sleep now…!! :heart_eyes:

@nomi This info will also help to grab some pakoras that have become cold as I was stuck here for a while now. Thanks @reinoudbosch

1 Like

But how can you explain this usage of a class
y = tf.keras.layers.ZeroPadding2D(padding=1)(x)

taken from tensorflow documentation

I mean : ZeroPadding2D is a class, so with any class (say ‘y’), we can use : y(some args) to instantiate an object of the class type.
But what does this → y(some args)(something) mean?

@ashish_learns Lol :joy:

@ashish_learns you will understand this while doing assignment of functional model. Actually it is like pipeline, in y = tf.keras.layers.ZeroPadding2D(padding=1)(x) assume x as a input that come from previous layer and in next layer, let suppose z = tf.keras.layers.MaxPool2D(pool_size=(2, 2), strides=None, padding='valid')(y) will be placed on x.

I have been using Python for more than 4 years and have never come across this type of programming construct, where apart from the usual () for instantiating object of a class, we also have an extra () just after this —> tf.keras.layers.ZeroPadding2D(padding=1)(x)

@ashish_learns yeah me too. I have also seen this format in only tensorflow.

bhai, if you get something about this then don’t forget to share here

@ashish_learns sure i will.

I would suggest this info be added to the assignment as a hint. There is no way we could find out that input_shape is a parameter, other than guessing, or hoping to find it here. I spent a lot of time trying to figure out how to make it work, only to find out there is some hidden parameter to use that’s not in the docs.


Thanks a lot with this hint. :wink: