DLS 4 Week 2 A2 Exercise 2 -- been stuck for quite some time

Would appreciate some guidance. Seems I am just lost and and trying random things.

Attached is the screen shot.

Thanks

Well the error tells you, your input to the model doesnt have the required shape, it has a dimension of 3 but it needs a dimension of 4. Its probably because you also need the batch dimension along with the images. Maybe by using tf.expand or np.newaxis … I am not familiar with the assingment but thats basically your problem.

Are you sure that you don’t have any trailing commas on any of the assignment statements? You have to be careful if you “copy/paste” things from the Sequential API to the Functional API. The two are fundamentally different. In the Sequential case, you need the commas, because what you are doing is creating a list. In the Functional case, if you put a comma at the end of the line, it makes the RHS of the assignment statement a tuple, which is not what you want and can result in errors like the one you show.

Here’s a thread which gives a nice introduction to the subtleties of the Sequential and Functional APIs.

1 Like

This helped. Thanks. (Still I feel I kind of hacked through rather than understand. Will get back to it later.)