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

余生长醉 提交于 2020-08-07 07:56:19

问题


I just started working with Keras 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.


回答1:


they are the same. you can test it by 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 operation (2D, 3D, avg, global pooling)




回答2:


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:



来源:https://stackoverflow.com/questions/63006575/what-is-the-difference-between-maxpool-and-maxpooling-layers-in-keras

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!