ValueError: Input 0 of layer max_pooling2d_43 is incompatible with the layer: expected ndim=4, found ndim=5. Full shape received: [1, None, 64, 64, 8]

What could this error mean?

It means that the previous layer you created outputs a 5D object, instead of a 4D object, which is what the following layer is expecting. One common cause of such an error is adding trailing commas on the lines that define the layers. Those are required when you are defining the layers using the Keras “Sequential” API, but not when you are using the “Functional” API. Please see this thread for another example of this error and some discussion of at least one possible way to cause that.

1 Like

I removed the commas and it worked! Thank you!


I had that issue too because I accidentally copied over a comma from the sequential code. Thanks, this saved me a ton of time.