Week 1 CNN Applications

Hello, I’ve been running into trouble in section 3.1’s exercise 1 happyModel.
My implementation for all the other layers are correct however I’ve been having trouble with the ZeroPadding2D command in the Sequential Model.

I’ve looked through the documentation online and I’ve googled different sites but I’m still not sure how to tell the ZeroPadding2D layer what the input dimensions are. I’ve attached a screenshot below of my code and error, could someone help me please?

Thank you!

Hi, I ran into this for some time as well.

As the comment in the code block wrote, we are implementing a layer with input shape of 64 x 64 x 3
So I put a Input Layer right before ZeroPadding2D

tfl.Input(shape = (64, 64, 3)),
tfl.ZeroPadding2D…

In your ZeroPadding2D layer, you did not specify the “shape = …” argument.

That’s not really correct either.

@TMosh
Thanks for reply, I didn’t see shape argument in the document
What have I missed?

I tried tfl.ZeroPadding2D(padding = 3, shape = (64, 64, 3)),
and the error message is (‘Keyword argument not understood:’, ‘shape’)

Thanks again

The comment directly above the line where you add tfl.ZeroPadding 2D() says so.

## ZeroPadding2D with padding 3, input shape of 64 x 64 x 3

This line of code works perfectly fine:

tfl.ZeroPadding2D(padding=3,input_shape=(64,64,3)),

The Keras documentation is not always totally complete. ZeroPadding2D() inherits from the Layer class. That’s where “input_shape” is defined.

I fixed it! Thank you!