I recently got the deep learning docker from https://github.com/floydhub/dl-docker running and while trying out the tutorials, received an error when importing the keras layers module.
from __future__ import print_function
import keras
from keras.datasets import cifar10
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Conv2D, MaxPooling2D
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-13-3a12c6f32fcf> in <module>()
5 from keras.models import Sequential
6 from keras.layers import Dense, Dropout, Activation, Flatten
----> 7 from keras.layers import Conv2D, MaxPooling2D
ImportError: cannot import name Conv2D
I am running with ubuntu 14.04, python version 2.7.6 on the ipython notebook and the following versions of the deep learning libraries on docker.
ARG THEANO_VERSION=rel-0.8.2
ARG TENSORFLOW_VERSION=0.12.1
ARG TENSORFLOW_ARCH=cpu
ARG KERAS_VERSION=1.2.0
ARG LASAGNE_VERSION=v0.1
ARG TORCH_VERSION=latest
ARG CAFFE_VERSION=master
Im not sure if the problem lies with the version because it seems that there no related issues on the github thread.
Try this: from keras.layers.convolutional import Conv2D
Importing changed with the new keras. Are you sure you are not using keras >= 2?
NOTE:
With tensorflow 2.0 keras is included. You can now import the layer with:
from tensorflow.keras.layers import Conv2D