0

I have followed link : https://github.com/mayanksatnalika/ipython/blob/master/embeddings%20project/safe_driver/Safe_driver_Kaggle.ipynb

but getting error NameError: name 'Merge' is not defined when i am running the following block :

from keras.layers import *
from keras.models import *

models = []

for categoical_var in categoical_vars :
  model = Sequential()
  no_of_unique_cat  = df_train[categoical_var].nunique()
  embedding_size = min(np.ceil((no_of_unique_cat)/2), 50 )
  embedding_size = int(embedding_size)
  model.add(  Embedding( no_of_unique_cat+1, embedding_size, input_length = 1 ) )
  model.add(Reshape(target_shape=(embedding_size,)))
  models.append( model )


  model_rest = Sequential()
  model_rest.add(Dense(16, input_dim= 43 ))
  models.append(model_rest)

  full_model = Sequential()
  full_model.add(Merge(models, mode='concat'))
  full_model.add(Dense(1000))
  full_model.add(Activation('relu'))
  full_model.add(Dense(400))
  full_model.add(Activation('relu'))
  full_model.add(Dense(200))
  full_model.add(Activation('sigmoid'))

  full_model.add(Dense(2))
  full_model.add(Activation('sigmoid'))
  full_model.compile(loss='binary_crossentropy', optimizer='adam',metrics=['accuracy'])

I am new to keras so followed many lniks .It seems Merge is not supported in Keras 2.0, tried many things but not able to get this working .

followed stackoverflow on these two, How to "Merge" Sequential models in Keras 2.0? and Keras - Merging layers - Keras 2.0 but not helping .

ajaypr55
  • 141
  • 2
  • 11
  • This is because `Merge` layer was removed in Keras2.0. You shoudl use `Concatenate` instead `Concatentae([..])` – enterML Dec 21 '18 at 07:19
  • concatenated = concatenate([models, full_model]) , gives ValueError: Unexpectedly found an instance of type ``. Expected a symbolic tensor instance. – ajaypr55 Dec 21 '18 at 07:40
  • 1
    As far as know, in Keras, you can not **concat** the models instead you can concatenate their outputs. – Amir Dec 21 '18 at 08:41

0 Answers0