Hi, I am having a problem with the convolutional_model exercise.
I get an error about incompatible layer sizes. In the screenshot I attached, I also put the result of printing Z1, A1.shape, and A1. So between Z1 and A1, somehow, an additional dimension was added (by the ReLU layer??). I don’t understand why that would be.
Hi @marie000
Please take a look at how to use the arguments of MaxPool2D in this link here and you will find what is wrong in your code.
Keep learning!
Thanks everyone. I somehow fixed it. I rewrote some of the lines and somehow it worked. I have no idea what was wrong the first time. I looked at it over and over again and never found anything wrong. At the end, the only difference I could see was some spacing in the parameters, which I doubt caused the issue in the first place.
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.
Right, that’s the one that I noticed, so that would have caused a problem later. But it “threw” before it got to that line, so my theory is that there must have been a similar error on one of the earlier lines that constructs the model.