1
$\begingroup$

The keras model looks like this

features_input = Input(shape=(features.shape[1],))
inp = Input(shape=(maxlen, ))
x = Embedding(max_features, embed_size, weights=[embedding_matrix], trainable=False)(inp)
x = Bidirectional(LSTM(num_filters, return_sequences=True))(x)
max_pool = GlobalMaxPooling1D()(x)
x = concatenate([x_h, max_pool,features_input])
outp = Dense(6, activation="sigmoid")(x)

What does GlobalMaxPooling1D()(x) really do to the output of LSTM? I know the input to LSTM layer is of dimension (batch_size, steps, features).

Does GlobalMaxPooling1D take max across num_filters/hidden units of each LSTM unit?

$\endgroup$
1
$\begingroup$

No, it takes max across steps.

Suppose the output x of your Bidirectional(LSTM()) has shape (batch_size, steps, hidden_size), then after GlobalMaxPooling1D() your max_pool would have shape (batch_size, hidden_size).

$\endgroup$
  • $\begingroup$ So is it "select batch_size, max(hidden_size) group by batch_size, steps" in terms of SQL? Not able to visualize it $\endgroup$ – GeorgeOfTheRF Sep 19 '18 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.