GlobalMaxPooling3DLayer - 3-D global max pooling layer - MATLAB (original) (raw)
3-D global max pooling layer
Description
A 3-D global max pooling layer performs downsampling by computing the maximum of the height, width, and depth dimensions of the input.
Creation
Syntax
Description
`layer` = globalMaxPooling3dLayer
creates a 3-D global max pooling layer.
`layer` = globalMaxPooling3dLayer('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
Object Functions
Examples
Create a 3-D global max pooling layer with name 'gmp1'
.
layer = globalMaxPooling3dLayer('Name','gmp1')
layer = GlobalMaxPooling3DLayer with properties:
Name: 'gmp1'
Include a 3-D max pooling layer in a Layer
array.
layers = [ ... image3dInputLayer([28 28 28 3]) convolution3dLayer(5,20) reluLayer globalMaxPooling3dLayer fullyConnectedLayer(10) softmaxLayer]
layers = 6×1 Layer array with layers:
1 '' 3-D Image Input 28×28×28×3 images with 'zerocenter' normalization
2 '' 3-D Convolution 20 5×5×5 convolutions with stride [1 1 1] and padding [0 0 0; 0 0 0]
3 '' ReLU ReLU
4 '' 3-D Global Max Pooling 3-D global max pooling
5 '' Fully Connected 10 fully connected layer
6 '' Softmax softmax
Tips
- In an image classification network, you can use a
globalMaxPooling3dLayer
before the final fully connected layer to reduce the size of the activations without sacrificing performance. The reduced size of the activations means that the downstream fully connected layers will have fewer weights, reducing the size of your network. - You can use a
globalMaxPooling3dLayer
towards the end of a classification network instead of a fullyConnectedLayer. Since global pooling layers have no learnable parameters, they can be less prone to overfitting and can reduce the size of the network. These networks can also be more robust to spatial translations of input data. You can also replace a fully connected layer with a globalAveragePooling3dLayer instead. Whether aglobalAveragPooling3dLayer
or aglobalMaxPooling3dLayer
is more appropriate depends on your data set.
To use a global average pooling layer instead of a fully connected layer, the size of the input toglobalMaxPooling3dLayer
must match the number of classes in the classification problem
Algorithms
A 3-D global max pooling layer performs downsampling by computing the maximum of the height, width, and depth dimensions of the input.
The dimensions that the layer pools over depends on the layer input:
- For 3-D image input (data with five dimensions corresponding to pixels in three spatial dimensions, the channels, and the observations), the layer pools over the spatial dimensions.
- For 3-D image sequence input (data with six dimensions corresponding to the pixels in three spatial dimensions, the channels, the observations, and the time steps), the layer pools over the spatial dimensions.
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 GlobalMaxPooling3DLayer
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 |
---|---|
"SSSCB" (spatial, spatial, spatial, channel, batch) | "SSSCB" (spatial, spatial, spatial, channel, batch) |
"SSSC" (spatial, spatial, spatial, channel) | "SSSC" (spatial, spatial, spatial, channel) |
In dlnetwork
objects, GlobalMaxPooling3DLayer
objects also support these input and output format combinations.
Input Format | Output Format |
---|---|
"SSSCBT" (spatial, spatial, spatial, channel, batch, time) | "SSSCBT" (spatial, spatial, spatial, channel, batch, time) |
"SSSCT" (spatial, spatial, spatial, channel, time) | "SSSCT" (spatial, spatial, spatial, channel, time) |
Version History
Introduced in R2020a