GlobalAveragePooling1DLayer - 1-D global average pooling layer - MATLAB (original) (raw)
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
Syntax
Description
`layer` = globalAveragePooling1dLayer
creates a 1-D global average pooling layer.
`layer` = globalAveragePooling1dLayer(Name=name)
sets the optional Name property.
Properties
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 a 1-D global average pooling layer.
layer = globalMaxPooling1dLayer
layer = GlobalMaxPooling1DLayer with properties:
Name: ''
Define the neural network architecture.
layers = [ sequenceInputLayer(12,MinLength=20) convolution1dLayer(11,96) reluLayer globalAveragePooling1dLayer fullyConnectedLayer(10) softmaxLayer]
layers = 6×1 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
Algorithms
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.
Global pooling layers remove the "T"
(time) dimension when the pool over the "T"
(time) dimension. Global pooling layers do not remove the "S"
(spatial) dimension when the pool over the "S"
(spatial) dimension.
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 GlobalAveragePooling1DLayer
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 |
---|---|
"SCB" (spatial, channel, batch) | "SCB" (spatial, channel, batch) |
"CBT" (channel, batch, time) | "CB" (channel, batch) |
"SCBT" (spatial, channel, batch, time) | "SCBT" (spatial, channel, batch, time) |
"SC" (spatial, channel) | "SC" (spatial, channel) |
"SB" (spatial, batch) | "SB" (spatial, batch) |
In dlnetwork
objects, GlobalAveragePooling1DLayer
objects also support these input and output format combinations.
Input Format | Output Format |
---|---|
"CT" (channel, time) | "CU" (channel, unspecified) |
"SCT" (spatial, channel, time) | "SCT" (spatial, channel, time) |
"BT" (batch, time) | "BU" (batch, unspecified) |
"SBT" (spatial, batch, time) | "SBT" (spatial, batch, time) |
GlobalAveragePooling1DLayer
objects support complex-valued input and outputs. (since R2024a) The layer applies the same underlying operation to complex-valued input as it does to real-valued input and outputs complex-valued data where applicable.
Extended Capabilities
Usage notes and limitations:
- You can generate generic C/C++ code that does not depend on third-party libraries and deploy the generated code to hardware platforms.
Usage notes and limitations:
- You can generate CUDA code that is independent of deep learning libraries and deploy the generated code to platforms that use NVIDIA® GPU processors.
Version History
Introduced in R2021b
GlobalAveragePooling1DLayer
objects support complex-valued input and outputs. The layer applies the same underlying operation to complex-valued input as it does to real-valued input and outputs complex-valued data where applicable.