How to use concat function layer on Keras 2.0.0?

I am trying to reproduce object injection models using Keras. Here is the github link and use the branch kaggle. There is one python file models.pyand a layer is used Merge.

from keras.layers.core import Dense, Dropout, Activation, Merge, Reshape ......
self.model.add(Merge(models, mode='concat'))

This code should be good for the old version of Keras, but using Keras 2.0.0, using shadoworflow 1.0.0 as the backend (python 2.7), there will be incorrect information: Using TensorFlow backend. Traceback (most recent call last): File "/Users/pengjuzhao/Udacity/MLND/entity-embedding-rossmann/test_model.py", line 2, in <module> from models import NN_with_EntityEmbedding File "/Users/pengjuzhao/Udacity/MLND/entity-embedding-rossmann/models.py", line 8, in <module> from keras.layers.core import Dense, Dropout, Activation, Merge, Reshape ImportError: cannot import name Merge [Finished in 1.8s with exit code 1] [shell_cmd: python -u "/Users/pengjuzhao/Udacity/MLND/entity-embedding-rossmann/test_model.py"] [dir: /Users/pengjuzhao/Udacity/MLND/entity-embedding-rossmann] [path: /usr/bin:/bin:/usr/sbin:/sbin]

Is there anyone who knows how to achieve the same goal ( self.model.add(Merge(models, mode='concat'))) or how to use the merge / merge level with Keras 2.0.0? Thanks in advance.

+6
source share
1 answer

, . :

from keras.layers import Merge

Github merge/Merge , .

Github post, .

Keras 1.2.2:

from keras.engine import merge
m = merge([init, x], mode='sum')

Keras 2.0.2:

from keras.layers import add
m = add([init, x])
+10

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


All Articles