globalAveragePooling2dLayer

Global average pooling layer

Description

A global average pooling layer performs down-sampling by computing the mean of the height and width dimensions of the input.

Creation

Description

layer = globalAveragePooling2dLayer creates a global average pooling layer.

example

layer = globalAveragePooling2dLayer('Name',name) sets the optional Name property.

Properties

expand all

Layer name, specified as a character vector or a string scalar. To include a layer in a layer graph, you must specify a nonempty unique layer name. If you train a series network with the layer and Name is set to '', then the software automatically assigns a name to the layer at training time.

Data Types: char | string

Number of inputs of the layer. This layer accepts a single input only.

Data Types: double

Input names of the layer. This layer accepts a single input only.

Data Types: cell

Number of outputs of the layer. This layer has a single output only.

Data Types: double

Output names of the layer. This layer has a single output only.

Data Types: cell

Examples

collapse all

Create a global average pooling layer with the name 'gap1'.

layer = globalAveragePooling2dLayer('Name','gap1')
layer = 
  GlobalAveragePooling2DLayer with properties:

    Name: 'gap1'

Include a global average pooling layer in a Layer array.

layers = [ ...
    imageInputLayer([28 28 1])
    convolution2dLayer(5,20)
    reluLayer
    globalAveragePooling2dLayer
    fullyConnectedLayer(10)
    softmaxLayer
    classificationLayer]
layers = 
  7x1 Layer array with layers:

     1   ''   Image Input              28x28x1 images with 'zerocenter' normalization
     2   ''   Convolution              20 5x5 convolutions with stride [1  1] and padding [0  0  0  0]
     3   ''   ReLU                     ReLU
     4   ''   Global Average Pooling   Global average pooling
     5   ''   Fully Connected          10 fully connected layer
     6   ''   Softmax                  softmax
     7   ''   Classification Output    crossentropyex

Introduced in R2019b