LSTM Followed by Mean Pooling

后端 未结 5 1457
清歌不尽
清歌不尽 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:44

    Adding TimeDistributed(Dense(1)) helped:

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

提交回复
热议问题