LSTM Followed by Mean Pooling

后端 未结 5 1447
清歌不尽
清歌不尽 2020-12-30 07:14

I\'m using Keras 1.0. My problem is identical to this one (How to implement a Mean Pooling layer in Keras), but the answer there does not seem to be sufficient for me.

5条回答
  •  自闭症患者
    2020-12-30 07:37

    Thanks, I also meet the question, but I think TimeDistributed layer not working as you want, you can try Luke Guye's TemporalMeanPooling layer, it works for me. Here is the example:

    sequence = Input(shape=(max_sent_len,), dtype='int32')
    embedded = Embedding(vocab_size, word_embedding_size)(sequence)
    lstm = LSTM(hidden_state_size, return_sequences=True)(embedded)
    pool = TemporalMeanPooling()(lstm)
    output = Dense(1, activation='sigmoid')(pool)
    

提交回复
热议问题