I am new to Keras.
My goal is to create a Neural Network Multi-Classification for Sentiment Analysis for tweets.
I used Sequential
in Keras
to build my model.
I want to use pre-trained word embeddings in the first layer of my model, specifically gloVe
.
Here is my model currently:
model = Sequential()
model.add(Embedding(vocab_size, 300, weights=[embedding_matrix], input_length=max_length, trainable=False))
model.add(LSTM(100, stateful=False))
model.add(Dense(8, input_dim=4, activation='relu'))
model.add(Dense(3, activation='softmax'))
embedding_matrix
is filled by the vectors coming from the file glove.840B.300d.txt
Since my input to the neural network model is sentences (or tweets), and after consulting some theory, I want for the layer after the Embedding layer, after taking every word vector in the tweet, to average the sentence’s word vectors.
Currently what I use is LSTM
, I want to replace it with this technique of averaging technique or p-means
. I wasn't able to find this in keras
documentation.
I'm not sure if this is the right place to ask this, but all help will be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…