I am trying to build text-summarizer using word Embeddings and encoder-decoder architecture. This is my first shot at Keras and I am not able to understand why layer_1
requires ndim=3
. I am not able to figure this out. Below is my code:
vocab_size = 16828
n_embeddings = 200
def model_builder(embeds):
model = keras.Sequential()
model.add(Embedding(weights=[embeds], name="embedding_1", input_dim=vocab_size,
output_dim=n_embeddings))
for i in range(3):
lstm = LSTM(rnn_size, name="layer_%s" %(i))
model.add(lstm)
model.add(Dropout(prob, name="drop_%s" %(i)))
model.add(Dense())
model.add(Activation('softmax', name="activation"))
return model
rnn_size = 200
prob = 0.5
encoder = model_builder(embedding)
encoder.compile(loss='categorical_crossentropy', optimizer='rmsprop')
enocder.save_weights('embeddings.pkl', overwrite=True)
I will really appreciate your help. Let me know if you guys need any other information. Thank you in advance.
P.S. Keras
backend is Tensorflow
.