Keras - Cannot import Conv2D name

Recently, I received an in-depth training docker from https://github.com/floydhub/dl-docker , and when testing tutorials, I received an error while importing keras module layers.

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 an ipython laptop and the following versions of 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

I'm not sure if the problem is version related, because it seems that there are no related problems in the github thread.

+4
source share
2 answers

Try the following: from keras.layers.convolutional import Conv2D

Import changed using new keras. Are you sure you are not using keras> = 2?

+4

Keras 1.2.0 ( floydhub print (keras.__ version __)) Conv2D ( ) Conv2DTranspose ( Keras):

from keras.layers import Convolution2D as Conv2D
from keras.layers.convolutional import Deconv2D as Conv2DTranspose
0

Source: https://habr.com/ru/post/1677751/


All Articles