Issue with import keras.layers.core.Merge as Merge (compatibility of keras 2 with previous keras version?)

9,980 views
Skip to first unread message

Jean-Patrick Pommier

unread,
Mar 22, 2017, 11:59:06 AM3/22/17
to Keras-users
Hi,

A notebook in :

https://github.com/imlab-uiip/keras-segnet

starts with some imports:

from keras.layers.core import Layer, Dense, Dropout, Activation, Flatten, Reshape, Merge, Permute
from keras.layers.convolutional import Convolution2D, MaxPooling2D, UpSampling2D, ZeroPadding2D
from keras.layers.normalization import BatchNormalization
from keras.callbacks import ModelCheckpoint

from keras import backend as K

As I tried to run that cell,the Merge module seems to be unknown:

---------------------------------------------------------------------------
ImportError Traceback (most recent call last) <ipython-input-8-82cbf4fe5266> in <module>()
----> 1 import keras.layers.core.Merge as Merge ImportError: No module named Merge

I suppose this is because I have keras 2.02 installed.

Is there a turn around to import this module?

Thanks.

olafv...@gmail.com

unread,
Mar 22, 2017, 12:13:34 PM3/22/17
to Keras-users
I think this has changed in 2. (But I never tried in 1.x) I follwed this: https://keras.io/getting-started/functional-api-guide/#multi-input-and-multi-output-models Apart from a missing 'import keras' on top that worked fine for me.

François Chollet

unread,
Mar 22, 2017, 3:33:08 PM3/22/17
to olafv...@gmail.com, Keras-users
You can import the legacy Merge layer via `from keras.layers import Merge`.

But note that you should no longer be using it. Instead, use the functional API.

--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users+unsubscribe@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/bca672a2-8893-407a-85bf-78ad801ab672%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

ramiredd...@gmail.com

unread,
Jul 20, 2018, 4:36:25 AM7/20/18
to Keras-users
you have to use, from from keras.layers import merge ( instead ' M ' replace 'm' )

mago...@gmail.com

unread,
Aug 2, 2019, 8:21:23 AM8/2/19
to Keras-users
ok thanks it works with from keras.layers import merge
Reply all
Reply to author
Forward
0 new messages