Z1=Conv2D(input_img), after that, should we continue
A1=ReLU()(Z1),
P1=MaxPool2D(A1),
Z2=Conv2D(P1),
A2=ReLU()(Z2),
P2=MaxPool2D(A2),
F=Flatten()(P2),
I got Input 0 of layer max_pooling2d_52 is incompatible with the layer: expected ndim=4, found ndim=5. Full shape received: [1, None, 64, 64, 8] after running the code.
If I miss any value like Z1,A1,etc, it says ’ ’ object has no attribute ‘shape’
Right! The point is that the syntax for the TF/Keras Functional API is different from the syntax for the TF/Keras Sequential API. Examples are given in the notebook.
It turns out that adding the trailing commas in the Functional API causes the RHS of the expression to become a “tuple”, which is (in most cases) not what was intended. If the RHS is already a Tensor, that causes it to sprout an unwanted additional dimension.
Thanks for the tip. I’ve been looking everywhere for a mistake in my code until I find here it’s only a problem of syntax. The course should stress on this kind of thing. I spent >1 hour looking for a fundamental problem when I could have passed the exercise in minutes.
Yes, sorry, the level of explanation they give in the notebook of these new and complex Keras constructs does leave a bit to be desired. You can find a lot more on the Keras documentation site or here is an excellent Discourse thread which covers all this and is definitely worth a look.