Main Content

adaptiveAveragePooling2dLayer

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

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.

example

Properties

expand all

Adaptive Average Pooling

Dimensions of the output size, specified as a vector of two positive integers [sz1 sz2]. When creating the layer, you can specify OutputSize 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

Layer name, specified as a character vector or string scalar. For Layer array input, the trainnet and dlnetwork functions automatically assign names to layers with the name "".

The AdaptiveAveragePooling2DLayer object stores this property as a character vector.

Data Types: char | string

This property is read-only.

Number of inputs to the layer, returned as 1. This layer accepts a single input only.

Data Types: double

This property is read-only.

Input names, returned as {'in'}. This layer accepts a single input only.

Data Types: cell

This property is read-only.

Number of outputs from the layer, returned as 1. This layer has a single output only.

Data Types: double

This property is read-only.

Output names, returned as {'out'}. This layer has a single output only.

Data Types: cell

Examples

collapse all

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.

Use properties method to see a list of 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 = 
  6x1 Layer array with layers:

     1   ''   Image Input                    28x28x1 images with 'zerocenter' normalization
     2   ''   2-D Convolution                20 5x5 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

expand all

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

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced in R2024a