Week1, assignment 2, exercise 2: shape problem

The problem is most likely that you had an extra comma at the end of one of the lines of code. You can see one such in the Conv2D layer right after the MaxPool2D layer that “threw” in the exception trace that you show. Maybe you had one of those commas in an earlier line. That has the effect of turning the RHS into a “tuple” and it adds an extra dimension.

You need the commas in the Sequential API, because you are building a list of instantiated layer functions. But they are a disaster in the Functional API where you are invoking instantiated layer functions with a tensor as input. Here’s a thread that is worth a look for a more complete explanation of how the Sequential and Functional APIs work.

1 Like