Ken
Ken

Reputation: 1481

What is the difference between MaxPool and MaxPooling layers in Keras?

I just started working with and noticed that there are two layers with very similar names for max-pooling: MaxPool and MaxPooling. I was surprised that I couldn't find the difference between these two on Google; so I am wondering what the difference is between the two if any.

Upvotes: 29

Views: 17584

Answers (3)

Marco Cerliani
Marco Cerliani

Reputation: 22031

They are the same... You can test it on your own

import numpy as np
import tensorflow as tf
from tensorflow.keras.layers import *

# create dummy data
X = np.random.uniform(0,1, (32,5,3)).astype(np.float32)

pool1 = MaxPool1D()(X)
pool2 = MaxPooling1D()(X)

tf.reduce_all(pool1 == pool2) # True

I used 1D max-pooling but the same is valid for all the pooling operations (2D, 3D, avg, global pooling)

Upvotes: 21

Md. Imrul Kayes
Md. Imrul Kayes

Reputation: 973

Ther are the same. The library is soo many times updated that's why there are some functions with different names but with the same tasks. you can use any of them.

Upvotes: 2

today
today

Reputation: 33470

They are basically the same thing (i.e. aliases of each other). For future readers who might want to know how this could be determined: go to the documentation page of the layer (you can use the list here) and click on "View aliases". This is then accompanied by a blue plus sign (+).

For example, if you go to MaxPool2D documentation and do this, you will find MaxPooling2D in the list of aliases of this layer as follow:

MaxPool aliases in Keras

Upvotes: 28

Related Questions