maxPooling3dLayer
3-D max pooling layer
Description
A 3-D max pooling layer performs downsampling by dividing three-dimensional input into cuboidal pooling regions, then computing the maximum of each region.
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.
For 2-D image sequence input (data with five dimensions corresponding to the pixels in two spatial dimensions, the channels, the observations, and the time steps), the layer pools over the spatial and time dimensions.
Creation
Description
creates a 3-D max pooling layer and sets thelayer
= maxPooling3dLayer(poolSize
)PoolSize
财产.
sets the optionallayer
= maxPooling3dLayer(poolSize
,Name,Value
)Stride
andName
properties using name-value pairs. To specify input padding, use the'Padding'
name-value pair argument. For example,maxPooling3dLayer(2,'Stride',3)
creates a 3-D max pooling layer with pool size[2 2 2]
and stride[3 3 3]
. You can specify multiple name-value pairs. Enclose each property name in single quotes.
Input Arguments
Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN
, whereName
is the argument name andValue
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.
Before R2021a, use commas to separate each name and value, and encloseName
in quotes.
Example:maxPooling3dLayer(2,'Stride',3)
creates a 3-D max pooling layer with pool size[2 2 2]
and stride[3 3 3]
.
Padding
—Input edge padding
0
(default) |array of nonnegative integers|'same'
Input edge padding, specified as the comma-separated pair consisting of'Padding'
and one of these values:
'same'
— Add padding of size calculated by the software at training or prediction time so that the output has the same size as the input when the stride equals 1.If the stride is larger than 1, then the output size isceil(inputSize/stride)
, whereinputSize
is the height, width, or depth of the input and步
is the stride in the corresponding dimension. The software adds the same amount of padding to the top and bottom, to the left and right, and to the front and back, if possible. If the padding in a given dimension has an odd value, then the software adds the extra padding to the input as postpadding. In other words, the software adds extra vertical padding to the bottom, extra horizontal padding to the right, and extra depth padding to the back of the input.Nonnegative integer
p
— Add padding of sizep
to all the edges of the input.Three-element vector
[a b c]
of nonnegative integers — Add padding of sizea
to the top and bottom, padding of sizeb
to the left and right, and padding of sizec
to the front and back of the input.2-by-3 matrix
[t l f;b r k]
of nonnegative integers — Add padding of sizet
to the top,b
to the bottom,l
to the left,r
to the right,f
to the front, andk
to the back of the input. In other words, the top row specifies the prepadding and the second row defines the postpadding in the three dimensions.
Example:'Padding',1
adds one row of padding to the top and bottom, one column of padding to the left and right, and one plane of padding to the front and back of the input.
Example:'Padding','same'
adds padding so that the output has the same size as the input (if the stride equals 1).
Properties
Max Pooling
PoolSize
—Dimensions of pooling regions
vector of three positive integers
Dimensions of the pooling regions, specified as a vector of three positive integers[h w d]
, whereh
is the height,w
is the width, andd
is the depth. When creating the layer, you can specifyPoolSize
as a scalar to use the same value for all three dimensions.
If the stride dimensionsStride
are less than the respective pooling dimensions, then the pooling regions overlap.
The padding dimensionsPaddingSize
must be less than the pooling region dimensionsPoolSize
.
Example:[2 1 1]
specifies pooling regions of height 2, width 1, and depth 1.
Stride
—Step size for traversing input
(1 1 1)
(default) |vector of three positive integers
Step size for traversing the input in three dimensions, specified as a vector[a b c]
of three positive integers, wherea
is the vertical step size,b
is the horizontal step size, andc
is the step size along the depth direction. When creating the layer, you can specifyStride
作为标量一步大小我使用相同的值n all three directions.
If the stride dimensionsStride
are less than the respective pooling dimensions, then the pooling regions overlap.
The padding dimensionsPaddingSize
must be less than the pooling region dimensionsPoolSize
.
Example:[2 3 1]
specifies a vertical step size of 2, a horizontal step size of 3, and a step size along the depth of 1.
PaddingSize
—Size of padding
[0 0 0;0 0 0]
(default) |2-by-3 matrix of nonnegative integers
Size of padding to apply to input borders, specified as 2-by-3 matrix[t l f;b r k]
of nonnegative integers, wheret
andb
are the padding applied to the top and bottom in the vertical direction,l
andr
are the padding applied to the left and right in the horizontal direction, andf
andk
are the padding applied to the front and back along the depth. In other words, the top row specifies the prepadding and the second row defines the postpadding in the three dimensions.
When you create a layer, use the'Padding'
name-value pair argument to specify the padding size.
Example:[1 2 4;1 2 4]
adds one row of padding to the top and bottom, two columns of padding to the left and right, and four planes of padding to the front and back of the input.
PaddingMode
—Method to determine padding size
'manual'
(default) |'same'
Method to determine padding size, specified as'manual'
or'same'
.
The software automatically sets the value ofPaddingMode
based on the 'Padding' value you specify when creating a layer.
If you set the
'Padding'
option to a scalar or a vector of nonnegative integers, then the software automatically setsPaddingMode
to'manual'
.If you set the
'Padding'
option to'same'
, then the software automatically setsPaddingMode
to'same'
and calculates the size of the padding at training time so that the output has the same size as the input when the stride equals 1.If the stride is larger than 1, then the output size isceil(inputSize/stride)
, whereinputSize
is the height, width, or depth of the input and步
is the stride in the corresponding dimension. The software adds the same amount of padding to the top and bottom, to the left and right, and to the front and back, if possible. If the padding in a given dimension has an odd value, then the software adds the extra padding to the input as postpadding. In other words, the software adds extra vertical padding to the bottom, extra horizontal padding to the right, and extra depth padding to the back of the input.
Layer
Name
—Layer name
''
(default) |character vector|string scalar
Layer name, specified as a character vector or a string scalar. ForLayer
array input, thetrainNetwork
,assembleNetwork
,layerGraph
, anddlnetwork
functions automatically assign names to layers with name''
.
Data Types:char
|string
NumInputs
—Number of inputs
1
(default)
This property is read-only.
Number of inputs of the layer. This layer accepts a single input only.
Data Types:double
InputNames
—Input names
{'in'}
(default)
This property is read-only.
Input names of the layer. This layer accepts a single input only.
Data Types:cell
NumOutputs
—Number of outputs
1
(default)
This property is read-only.
Number of outputs of the layer. This layer has a single output only.
Data Types:double
OutputNames
—Output names
{'out'}
(default)
This property is read-only.
Output names of the layer. This layer has a single output only.
Data Types:cell
Examples
Create Max Pooling 3-D Layer with Nonoverlapping Pooling Regions
Create a max pooling 3-D layer with nonoverlapping pooling regions.
layer = maxPooling3dLayer(2,'Stride',2)
layer = MaxPooling3DLayer with properties: Name: '' NumOutputs: 1 OutputNames: {'out'} Hyperparameters PoolSize: [2 2 2] Stride: [2 2 2] PaddingMode: 'manual' PaddingSize: [2x3 double]
The height, width, and depth of the cuboidal regions (pool size) are 2. The step size for traversing the images (stride) is 2 in all dimensions. The pooling regions do not overlap because the stride is greater than or equal to the corresponding pool size in all dimensions.
包括一个马克斯池层不重叠的再保险gions in aLayer
array.
layers = [...image3dInputLayer([28 28 28 3]) convolution3dLayer(5,20) reluLayer maxPooling3dLayer(2,'Stride',2) fullyConnectedLayer(10) softmaxLayer classificationLayer]
layers = 7x1 Layer array with layers: 1 '' 3-D Image Input 28x28x28x3 images with 'zerocenter' normalization 2 '' Convolution 20 5x5x5 convolutions with stride [1 1 1] and padding [0 0 0; 0 0 0] 3 '' ReLU ReLU 4 '' 3-D Max Pooling 2x2x2 max pooling with stride [2 2 2] and padding [0 0 0; 0 0 0] 5 '' Fully Connected 10 fully connected layer 6 '' Softmax softmax 7 '' Classification Output crossentropyex
Create Max Pooling 3-D Layer with Overlapping Pooling Regions
Create a max pooling 3-D layer with overlapping pooling regions and padding for the top and bottom of the input.
layer = maxPooling3dLayer([3 2 2],'Stride',2,'Padding',[1 0 0])
layer = MaxPooling3DLayer with properties: Name: '' NumOutputs: 1 OutputNames: {'out'} Hyperparameters PoolSize: [3 2 2] Stride: [2 2 2] PaddingMode: 'manual' PaddingSize: [2x3 double]
This layer creates pooling regions of size 3-by-2-by-2 and takes the maximum of the twelve elements in each region. The stride is 2 in all dimensions. The pooling regions overlap because there are stride dimensionsStride
that are less than the respective pooling dimensionsPoolSize
.
Algorithms
3-D Max Pooling Layer
A 3-D max pooling layer extends the functionality of a max pooling layer to a third dimension, depth. A max pooling layer performs down-sampling by dividing the input into rectangular or cuboidal pooling regions, and computing the maximum of each region. To learn more, see the definition ofmax pooling layeron themaxPooling2dLayer
reference page.
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.
For 2-D image sequence input (data with five dimensions corresponding to the pixels in two spatial dimensions, the channels, the observations, and the time steps), the layer pools over the spatial and time dimensions.
Layer Input and Output Formats
Layers in a layer array or layer graph pass data specified as formatteddlarray
objects.
You can interact with thesedlarray
objects in automatic differentiation workflows such as when developing a custom layer, using afunctionLayer
object, or using theforward
andpredict
functions withdlnetwork
objects.
This table shows the supported input formats ofMaxPooling3DLayer
objects and the corresponding output format. If the output of the layer is passed to a custom layer that does not inherit from thennet.layer.Formattable
class, or aFunctionLayer
object with theFormattable
option set tofalse
, then the layer receives an unformatteddlarray
object with dimensions ordered corresponding to the formats outlined in this table.
Input Format | Output Format |
---|---|
|
|
|
|
|
|
版本历史
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- Denmark(English)
- Deutschland(Deutsch)
- España(Español)
- Finland(English)
- France(Français)
- Ireland(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- Norway(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)