Please check the dimensionality of output of convolutional layers. I spent a whole day to figure out it. I used Tensorflow 2.4.0 on my PC, and Tensorflow 2.5.0 on Colab, and there were no issue. However, after I updated Tensorflow 2.4 to 2.5 on my PC, this error occurs for the same codes, and I don’t know why. I reinstalled Tensorflow 2.4 and Tensorflow 2.5 more than 20 times following several tutorials on different CUDA versions and CDNN versions but still has this error. I change the data reader method (not Keras, solo Tensorflow) but still give me this error. Then I train different part of my neural network, but still the error. But thanks to God, I deleted the ZeroPadding layer, and get out of the error. Thus, I think Tensorflow 2.5 changes the way to calculate the output dimensions of CNN. Hope it help!
FK Tf.2.5