AdaptiveAveragePooling2DLayer - Adaptive average pooling 2-D layer - MATLAB (original) (raw)
Adaptive average pooling 2-D layer
Since R2024a
Description
A 2-D adaptive average pooling layer performs downsampling to give you the desired output size by dividing the input into rectangular pooling regions, then computing the average of each region.
Creation
Syntax
Description
`layer` = adaptiveAveragePooling2dLayer(`outputSize`)
creates an adaptive average pooling layer and sets the OutputSize
property.
`layer` = adaptiveAveragePooling2dLayer(Name=`name`)
sets the optional Name property. For example, adaptiveAveragePooling2dLayer(16,Name="adap")
creates an adaptive average pooling layer with output size [16 16]
and sets the optional Name
property.
Properties
Adaptive Average Pooling
Dimensions of the output size, specified as a vector of two positive integers[sz1 sz2]
. When creating the layer, you can specifyOutputSize
as a scalar to use the same value for both dimensions.
Example: [12 14]
specifies output size of 12 and 14 for the lengths of first and second dimensions respectively.
Layer
Data Types: char
| string
This property is read-only.
Number of inputs to the layer, stored as 1
. This layer accepts a single input only.
Data Types: double
This property is read-only.
Input names, stored as {'in'}
. This layer accepts a single input only.
Data Types: cell
This property is read-only.
Number of outputs from the layer, stored as 1
. This layer has a single output only.
Data Types: double
This property is read-only.
Output names, stored as {'out'}
. This layer has a single output only.
Data Types: cell
Examples
Create an adaptive average pooling layer with the output size [12 12] name "adap_avg1"
.
layer = adaptiveAveragePooling2dLayer(12,Name="adap_avg1")
layer = AdaptiveAveragePooling2DLayer with properties:
Name: 'adap_avg1'
OutputSize: [12 12]
Learnable Parameters No properties.
State Parameters No properties.
Show all properties
Include an adaptive average pooling layer with the output size [12 12] in a Layer
array. The layer automatically selects the stride and kernel-size to give you the specified output size.
layers = [ ... imageInputLayer([28 28 1]) convolution2dLayer(5,20) reluLayer adaptiveAveragePooling2dLayer(12) fullyConnectedLayer(10) softmaxLayer]
layers = 6×1 Layer array with layers:
1 '' Image Input 28×28×1 images with 'zerocenter' normalization
2 '' 2-D Convolution 20 5×5 convolutions with stride [1 1] and padding [0 0 0 0]
3 '' ReLU ReLU
4 '' 2-D Adaptive Average Pooling Adaptive average pooling with output size 12x12
5 '' Fully Connected 10 fully connected layer
6 '' Softmax softmax
Algorithms
A 2-D adaptive average pooling layer performs downsampling by dividing the input into rectangular pooling regions, then computing the average of each region.
The dimensions that the layer pools over depends on the layer input:
- For 2-D image input (data with four dimensions corresponding to pixels in two spatial dimensions, the channels, and the observations), the layer pools over the spatial dimensions.
- For 2-D image sequence input (data with five dimensions corresponding to the pixels in two spatial dimensions, the channels, the observations, and the time steps), the layer pools over the spatial dimensions.
- For 1-D image sequence input (data with four dimensions corresponding to the pixels in one spatial dimension, the channels, the observations, and the time steps), the layer pools over the spatial and time dimensions.
Layers in a layer array or layer graph pass data to subsequent layers as formatted dlarray objects. The format of a dlarray
object is a string of characters in which each character describes the corresponding dimension of the data. The format consists of one or more of these characters:
"S"
— Spatial"C"
— Channel"B"
— Batch"T"
— Time"U"
— Unspecified
For example, you can describe 2-D image data that is represented as a 4-D array, where the first two dimensions correspond to the spatial dimensions of the images, the third dimension corresponds to the channels of the images, and the fourth dimension corresponds to the batch dimension, as having the format "SSCB"
(spatial, spatial, channel, batch).
You can interact with these dlarray
objects in automatic differentiation workflows, such as those for developing a custom layer, using a functionLayer object, or using the forward and predict functions withdlnetwork
objects.
This table shows the supported input formats of AdaptiveAveragePooling2DLayer
objects and the corresponding output format. If the software passes the output of the layer to a custom layer that does not inherit from the nnet.layer.Formattable
class, or aFunctionLayer
object with the Formattable
property set to 0
(false
), then the layer receives an unformatted dlarray
object with dimensions ordered according to the formats in this table. The formats listed here are only a subset. The layer may support additional formats such as formats with additional "S"
(spatial) or"U"
(unspecified) dimensions.
Input Format | Output Format |
---|---|
"SSCB" (spatial, spatial, channel, batch) | "SSCB" (spatial, spatial, channel, batch) |
"SCBT" (spatial, channel, batch, time) | "SCBT" (spatial, channel, batch, time) |
"SSCBT" (spatial, spatial, channel, batch, time) | "SSCBT" (spatial, spatial, channel, batch, time) |
"SSB" (spatial, spatial, batch) | "SSB" (spatial, spatial, batch) |
"SSC" (spatial, spatial, channel) | "SSC" (spatial, spatial, channel) |
"SCT" (spatial, channel, time) | "SCT" (spatial, channel, time) |
"SSCT" (spatial, spatial, channel, time) | "SSCT" (spatial, spatial, channel, time) |
"SBT" (spatial, batch, time) | "SBT" (spatial, batch, time) |
"SSBT" (spatial, spatial, batch, time) | "SSBT" (spatial, spatial, batch, time) |
References
[1] Nagi, J., F. Ducatelle, G. A. Di Caro, D. Ciresan, U. Meier, A. Giusti, F. Nagi, J. Schmidhuber, L. M. Gambardella. ''Max-Pooling Convolutional Neural Networks for Vision-based Hand Gesture Recognition''.IEEE International Conference on Signal and Image Processing Applications (ICSIPA2011), 2011.
Extended Capabilities
Version History
Introduced in R2024a