I have thoroughly read all the documentation on tf.keras.layers, The Sequential Model and the individual layers. I have also read curious.ai’s posting. None of them seem to address the issue I have.
It seems to be throwing the AttributeError because of something in the ZeroPadding2D line. I have the commas and the brackets exactly like in the documentation.
Please advise
We can see from the trace that the exception is thrown while examining the attribute data_format
. According to the doc, that parameter is supposed to be a string
with value either channels_last
or channels_first
. Instead, you have a Python tuple
and tuples don’t implement a function lower
, hence the error. NOTE: if data_format
is a string, the very next line checks the value, and throws an exception if it isn’t either channels_first
or channels_last
.
FWIW, that tuple looks suspiciously like an input_shape
. In the above Conv2D
doc look for the part that says When using this layer as the first layer in a model, provide the keyword argument input_shape
(tuple of integers…
Or take a quick peek at the Sequential model doc here
and look for the part that starts… A simple alternative is to just pass an input_shape
argument to your first layer:
I have now added content covering this to my Tips for troubles with Sequential and Functional API syntax thread
1 Like
Thank you very much for this and I have read many of your posts with great interest. I agree with the input_shape suggestion - its a shame the notebook instructions say “Note that for simplicity and grading purposes, you’ll hard-code all the values such as the stride and kernel (filter) sizes.”. I misinterpreted that.
I also note that in the data_format section of args in the tf.keras.layers.ZeroPadding2D documentation, it concludes with " It defaults to the image_data_format
value found in your Keras config file at ~/.keras/keras.json
. If you never set it, then it will be “channels_last”.
I am sure that with your advice I will sort this out.
Thanks again.
1 Like
That is the TF/Keras default, and is consistent with the practice used throughout the deeplearning classes, (m=#inputs, h=input height, w=input width, c=# channels). So most of the time you won’t need to set it in these classes, though there is no downside to being in the habit of explicitly stating it. Cheers