주요 콘텐츠

adaptiveAveragePooling2dLayer

R2026b

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(outputSize,Name=name) also sets the optional Name property. For example, adaptiveAveragePooling2dLayer(16,Name="adap") creates an adaptive average pooling layer with an output size of [16 16] and sets the name to "adap".

example

Input Arguments

expand all

Output size, specified as one of these:

  • Positive integer sz — Output data of size of [sz sz].

  • Vector of two positive integers [sz1 sz2] — Output data of size [sz1 sz2].

This argument sets the OutputSize property.

Example: [12 14] specifies output size of 12 and 14 for the lengths of first and second dimensions respectively.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

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

This argument sets the Name property.

Data Types: char | string

Properties

expand all

Adaptive Average Pooling

Output size, specified as a vector of two positive integers.

When you set this property, you can also specify a scalar value to use the same value for both dimensions.

Data Types: double

Layer

Layer name, specified as a character vector. For Layer array input, the trainnet and dlnetwork functions automatically assign names to unnamed layers.

Data Types: char

This property is read-only.

Number of inputs to the layer, represented as 1. This layer has a single input only.

Data Types: double

This property is read-only.

Input name, represented as {'in'}. This layer has a single input only.

This property is read-only.

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

Data Types: double

This property is read-only.

Output name, represented as {'out'}. This layer has a single output only.

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.

  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                Fully connected layer with output size 10
     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

expand all

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