C4_W1-Assig2_Ex2. Shape error

Trying to solve this error I put P2 as input for Flatten(), but then the same error appears in the precedent layer. But the shape is already defined in the first line as input_shape isn’t it?.

In fact I tried a lot of things but all of them gave errors. Can you help me?.

Many thanks

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.

Yes, has a lot of sense. In fact I’d tried to build the full chain but I made errors with ReLU() and Flatten() and I abandoned the idea.

Many thanks.