ImportError: cannot import name 'MaxPooling2D'

Viewed 7189

This is Keras API as Poling Layer importing problems, Below the code,

import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPoling2D
from keras.layers import backend as k

And now error is,

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-5eca71dc08e4> in <module>
      3 from keras.models import Sequential
      4 from keras.layers import Dense, Dropout, Flatten
----> 5 from keras.layers import Conv2D, MaxPoling2D
      6 from keras.layers import backend as k
      7 

ImportError: cannot import name 'MaxPoling2D'

Query: Need help for installing or setup poling layer in anaconda required version of Python 3.6.0 .

Note: I am using created environment as py36. because it was to difficult to install Tensorflow and keras where I used Python 3.7.0 . That's why I create new environment where python version is Python 3.6.0 .

2 Answers

First of all thanks a lot for everyone who try to make a solution and who already post the solutions. Finally, I could make a perfect solution and thatis,

from tensorflow.keras.layers import Conv2D, MaxPooling2D

I should use tensorflow.keras.layers Because keras module or API is available in Tensrflow 2.0

Thanks everyone !

Related