Soad Saleh
Soad Saleh

Reputation: 83

not Understanding GlobalMaxPooling1D keras

I am not sure if I understand well the GlobalMaxPooling1D in Keras. I have feature vector of text of uni gram & bi gram & tri and I concatenate them to be in form of [ ? , 3 , 256 ] and then I apply GlobalMaxPooling1D.

So, does GlobalMaxPooling1D select the best feature vector and return (batch_size, features)?

Upvotes: 1

Views: 964

Answers (1)

Kristian Aurlien
Kristian Aurlien

Reputation: 31

The GlobalMaxPooling1D layer does not select the best feature vector, but simply takes the maximum value of either feature vector from each of the 256 features.

As an example, imagine that for one sample, your three feature vectors looks like this:

v1 = [1, 0, 0, 0, ...]
v2 = [0, 1, 0, 0, ...]
v3 = [0, 0, 1, 0, ...]

After performing the GlobalMaxPooling1D operation, you would have a feature vector that looked like this, of shape (n_features):

v = [1, 1, 1, 0, ...]

When performed on a batch, this operation is performed on each sample in the batch. The size of the returned tensor will then, as you say, have a shape (batch_size, n_features).

Upvotes: 2

Related Questions