Sentence embedding in keras

时光怂恿深爱的人放手 提交于 2020-01-23 03:59:25

问题


I am trying a simple document classification using sentence embeddings in keras.

I know how to feed word vectors to a network, but I have problems using sentence embeddings. In my case, I have a simple representation of sentences (adding the word vectors along the axis, for example np.sum(sequences, axis=0)).

My question is, what should I replace the Embedding layer with in the code below to feed sentence embeddings instead?

model = Sequential()
model.add(Embedding(len(embedding_weights), len(embedding_weights[0]), weights=[embedding_weights], mask_zero=True, 
input_length=MAX_SEQUENCE_LENGTH, trainable=True))
model.add(LSTM(LSTM_SIZE, activation='relu'))

I've tried Embedding layer (without setting the weights) and Input layer but both gave errors.

来源:https://stackoverflow.com/questions/45001437/sentence-embedding-in-keras

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!