Week 1 Assignment 2 Input Shape configuration

I’ll try to point out something that stuck out in this assignment without actually sharing anything of value for completing the assignment.

The assignment instructs you to use a ZeroPadding2D layer with an input shape of 64 x 64 x 3. This seems to be the intention of the person who wrote the assignment:

## ZeroPadding2D with padding 3, input shape of 64 x 64 x 3
tfl.ZeroPadding2D(..., input_shape=(64, 64, 3)),

However, this is not actually documented in the ZeroPadding2D documentation, and is a bit of a nasty subtle gotcha to just casually have sitting there with no emphasis to be cautious of it, or where to look in the Keras documentation to solve it.

It seems like it might not even be idiomatic Keras usage - from reading the Keras documentations, it seems there is an Input layer that is intended to be used for setting the shape:

# Define input shape of 64 x 64 x 3
tfl.Input(shape=(64, 64, 3)),
## ZeroPadding2D with padding 3, input shape of 64 x 64 x 3
tfl.ZeroPadding2D(...), 

Here is an example from the Keras documentation: Simple MNIST convnet

The assignment is probably fine as is - but it seems like an unnecessary use of time to have people getting stuck on such a trivial piece of configuration rather than on the actual ConvNet itself. Adding the Input layer to the assignment documentation, or otherwise suggesting how to configure the input shape would be a useful improvement, I feel.

Thanks for your suggestion.

TensorFlow documentation is no thing of beauty, to be sure.

Note that ZeroPadding2D() inherits from Layer, which supports the input_shape parameter.

There is more than one way to specify the input shape. This assignment uses one of the methods, without much explanation.

1 Like