C4_W1-Assig2_Ex2. Shape error

The problem is that you are not providing inputs for the various “layer” functions here. This is the Keras Functional API, as opposed to the Sequential API that was used in the first part of this assignment. Each function is first “instantiated” by calling it with the layer parameters that you want. That returns you a function, which you then invoke with a tensor as argument and it gives a tensor as the output. So there need to be two disjoint sets of parentheses on the RHS of all those layer function expressions.

In the three lines of code we can see in your exception trace, you’ve done it correctly only on the “Dense” line. On the MaxPool and Flatten lines, you don’t provide an input tensor, so the output of that line (the LHS) will end up being a function, not a tensor. That’s what that error is telling you, although I grant you that it could be a lot clearer. :scream_cat:

They haven’t given us much guidance here about how to use the Sequential and Functional APIs and the documentation is not so easy to use either. Here’s a thread put together by ai_curious which is probably the best next step to understanding how to use these constructs.