Created
July 30, 2019 07:13
-
-
Save JustAyush/e7a43d47fa13cca80e0bb740381e8252 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
embedding_size = 5 | |
# creating book embedding path | |
book_input = Input(shape=[1], name="Book-Input") | |
book_embedding = Embedding(n_books2, embedding_size, name="Book-Embedding")(book_input) | |
# book_vec = Flatten(name="Flatten-Books")(book_embedding) | |
book_vec = Reshape([embedding_size])(book_embedding) | |
# creating user embedding path | |
user_input = Input(shape=[1], name="User-Input") | |
user_embedding = Embedding(n_users2, embedding_size, name="User-Embedding")(user_input) | |
# user_vec = Flatten(name="Flatten-Users")(user_embedding) | |
user_vec = Reshape([embedding_size])(user_embedding) | |
# concatenate features | |
conc = Concatenate()([book_vec, user_vec]) | |
x = Dense(16, activation='relu')(conc) | |
x = Dense(8, activation='relu')(x) | |
# # x = Dropout(0.3)(x) | |
# x = Dense(128, activation='relu')(x) | |
# # x = Dropout(0.2)(x) | |
# # x = Dense(64, activation='relu')(x) | |
# x = Dropout(0.5)(x) | |
# x = Dense(16, activation='relu')(x) | |
x = Dense(4)(x) | |
y = Dense(1)(x) | |
model2 = Model(inputs=[user_input, book_input], outputs=y) | |
model2.compile(optimizer='adam', loss='mse') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment