0

I am working on keras. I am new to kears. Here is my code for creating movie vectors and user vectors. After applying flatten its gives empty tensor.

movie_input = keras.layers.Input(shape=[1])
movie_vec = keras.layers.Flatten()(keras.layers.Embedding(n_movies + 1, 32) 
(movie_input))
movie_vec = keras.layers.Dropout(0.5)(movie_vec)
print(movie_vec)

# Same thing for the users
user_input = keras.layers.Input(shape=[1])
user_vec = keras.layers.Flatten()(keras.layers.Embedding(n_users + 1, 32) 
(user_input))
user_vec = keras.layers.Dropout(0.5)(user_vec)
print(user_vec)

input_vecs = keras.layers.merge([movie_vec, user_vec], mode='concat')
nn = keras.layers.Dropout(0.5)(keras.layers.Dense(128, activation='relu')    (input_vecs))
nn = keras.layers.normalization.BatchNormalization()(nn)
nn = keras.layers.Dropout(0.5)(keras.layers.Dense(128, activation='relu')(nn))
nn = keras.layers.normalization.BatchNormalization()(nn)
nn = keras.layers.Dense(128, activation='relu')(nn)

It gives me this error

>TypeError                                 Traceback (most recent call last)
>cc<ipython-input-27-10f282af0460> in <module>()
 18 # Next, we join them all together and put them
 19 # through a pretty standard deep learning architecture
 20 input_vecs = keras.layers.merge([movie_vec, user_vec], mode='concat')
 21 nn = keras.layers.Dropout(0.5)(keras.layers.Dense(128,activation='relu')(input_vecs))
 22 nn = keras.layers.normalization.BatchNormalization()(nn)
 >TypeError: 'module' object is not callable
1
  • which version you are using Commented Oct 4, 2018 at 13:51

2 Answers 2

1

Use keras 2.1.5

keras.layers.merge method available in it

Sign up to request clarification or add additional context in comments.

1 Comment

I have downgraded my keras version to 2.1.5. It's working for me. Thanks!
0

keras.layers.merge is not a callable. It is a module. Check out its documentation

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.