This might make it easier to read: I have run the same code on google Colab for MLP and a CNN:

Screenshot from 2019-07-21 00-06-14.png1259×519 72.1 KB

error on CNN:

Screenshot from 2019-07-21 00-09-41.png1214×430 50.7 KB

Executed it piece-wise and got this error:

Screenshot from 2019-07-21 00-14-07.png1226×291 44.6 KB