word_model=Sequential() word_model.add(Embedding(vocab_size,embed_size, embeddings_initializer="glorot_uniform", input_length=1)) word_model.add(Reshape((embed_size,)))
context_model=Sequential() context_model.add(Embedding(vocab_size,embed_size, embeddings_initializer="glorot_uniform", input_length=1)) context_model.add(Reshape((embed_size,)))
model=Sequential()model.add(Merge([word_model,context_model],mode="dot")) model.add(Dense(1,init="glorot_unifor",activation="sigmod")) model.compile(loss="mean_squared_error",optimizer="adam")
how to change those in keras2, which has no merge methods any more
The Merge
API has been changed. The new API is documented here.
In your example, instead of doing this:
Merge([word_model,context_model],mode="dot")
Do this:
keras.layers.dot([word_model,context_model])
and it should work!