I'm using CNNs in Keras
for an NLP task and instead of max pooling, I'm trying to achieve max over time pooling.
Any ideas/hacks on how to achieve this?
What I mean by max over time pooling is to pool the highest value, no matter where they are in the vector
The max-over-time pooling operation is very simple: max_c = max(c) , i.e., it's a single number that gets a max over the whole feature map. The reason to do this, instead of "down-sampling" the sentence like in a CNN, is that in NLP the sentences naturally have different length in a corpus.
Max pooling operation for 2D spatial data. Downsamples the input along its spatial dimensions (height and width) by taking the maximum value over an input window (of size defined by pool_size ) for each channel of the input. The window is shifted by strides along each dimension.
Average pooling method smooths out the image and hence the sharp features may not be identified when this pooling method is used. Max pooling selects the brighter pixels from the image. It is useful when the background of the image is dark and we are interested in only the lighter pixels of the image.
max-pooling layer gave the largest value in a certain subarea as an output, while the global max-pooling did this in the whole area. Figure 4 shows the difference. If MR data adopted global max-pooling, the large number of missing values would be discovered. ...
Assuming that your data shape is (batch_size, seq_len, features)
you may apply:
seq_model = Reshape((seq_len * features, 1))(seq_model)
seq_model = GlobalMaxPooling1D()(seq_model)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With