![]() |
VOOZH | about |
tf.keras.layers.AveragePooling2D is a layer in TensorFlow that performs average pooling on a 2D input tensor. Unlike max pooling, which retains only the maximum value from each pooling window, average pooling calculates the mean of all values in the window.
keras.layers.AveragePooling2D(
pool_size=(2, 2),
strides=None,
padding='valid',
data_format=None,
**kwargs
)
Parameters of Average Pooling 2D:
Let’s create a simple example to understand the working of AveragePooling2D.
Output:
Input Data: [[[[ 1.]
[ 2.]
[ 3.]
[ 4.]]
[[ 5.]
[ 6.]
[ 7.]
[ 8.]]
[[ 9.]
[10.]
[11.]
[12.]]
[[13.]
[14.]
[15.]
[16.]]]]
Output after Average Pooling Operation: [[[[ 3.5]
[ 5.5]]
[[11.5]
[13.5]]]]
The pool_size=(2,2) means each 2×2 block of input data is averaged:
AveragePooling2D reduces spatial dimensions, smoothens the feature maps and reduce the number of parameters minimizing overfitting.