Main Content

globalAveragePooling1dLayer

1-D global average pooling layer

Since R2021b

    Description

    A 1-D global average pooling layer performs downsampling by outputting the average of the time or spatial dimensions of the input.

    The dimension that the layer pools over depends on the layer input:

    • For time series and vector sequence input (data with three dimensions corresponding to the "C" (channel), "B" (batch), and "T" (time) dimensions), the layer pools over the "T" (time) dimension.

    • For 1-D image input (data with three dimensions corresponding to the "S" (spatial), "C" (channel), and "B" (batch) dimensions), the layer pools over the "S" (spatial) dimension.

    • For 1-D image sequence input (data with four dimensions corresponding to the "S" (spatial), "C" (channel), "B" (batch), and "T" (time) dimensions), the layer pools over the "S" (spatial) dimension.

    Creation

    Description

    example

    layer = globalAveragePooling1dLayer creates a 1-D global average pooling layer.

    layer = globalAveragePooling1dLayer(Name=name) sets the optional Name property.

    Properties

    expand all

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

    The GlobalAveragePooling1DLayer 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 a 1-D global average pooling layer.

    layer = globalMaxPooling1dLayer
    layer = 
      GlobalMaxPooling1DLayer with properties:
    
        Name: ''
    
    

    Include a 1-D global average pooling layer in a layer array.

    layers = [
        sequenceInputLayer(12,MinLength=20)
        convolution1dLayer(11,96)
        reluLayer
        globalAveragePooling1dLayer
        fullyConnectedLayer(10)
        softmaxLayer
        classificationLayer]
    layers = 
      7x1 Layer array with layers:
    
         1   ''   Sequence Input               Sequence input with 12 dimensions
         2   ''   1-D Convolution              96 11 convolutions with stride 1 and padding [0  0]
         3   ''   ReLU                         ReLU
         4   ''   1-D Global Average Pooling   1-D global average pooling
         5   ''   Fully Connected              10 fully connected layer
         6   ''   Softmax                      softmax
         7   ''   Classification Output        crossentropyex
    

    Algorithms

    expand all

    Version History

    Introduced in R2021b