Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use max pooling to gather information from LSTM nodes

gru_out = Bidirectional(GRU(hiddenlayer_num, return_sequences=True))(embedded)
#Tensor("concat_v2_8:0", shape=(?, ?, 256), dtype=float32)

I use Keras to create a GRU model.I want to gather information from all the node vectors of the GRU model, instead of the last node vector. For example, I need to get the maximum value of each vector, like the image description, but I have no idea on how to do this. enter image description here

like image 929
Lieutenant_Tom Avatar asked Mar 19 '17 13:03

Lieutenant_Tom


1 Answers

One may use GlobalMaxPooling1D described here:

gru_out = Bidirectional(GRU(hiddenlayer_num, return_sequences=True))(embedded)
max_pooled = GlobalMaxPooling1D(gru_out)
like image 57
Marcin Możejko Avatar answered Oct 18 '22 16:10

Marcin Możejko