averagePooling3dLayer
R2026b3-D average pooling layer
Description
A 3-D average pooling layer performs downsampling by dividing three-dimensional input into cuboidal pooling regions, then computing the average values 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
specifies options using one or more name-value arguments. For example,
layer = averagePooling3dLayer(poolSize,Name=Value)averagePooling3dLayer(2,Stride=2) creates a 3-D average pooling layer
with a pool size of two and a stride of two.
Input Arguments
Size of pooling regions, specified as one of these:
Positive integer
sz— Usesz-by-sz-by-szpooling regions.Vector of three positive integers
[h w d]— Useh-by-w-by-dpooling regions.
If the stride sizes Stride are less than the respective
pooling sizes, then the pooling regions overlap.
The sizes of the pooling regions must be greater than or equal to the
corresponding PaddingSize values.
This argument sets the PoolSize
property.
Example:
[2 1 1] specifies pooling regions of height 2, width 1, and depth
1.
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value 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 enclose
Name in quotes.
Example: averagePooling3dLayer(2,Stride=2) creates a 3-D average
pooling layer with a pool size of two and a stride of two.
Input edge padding, specified as 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), whereinputSizeis the height, width, or depth of the input andstrideis 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 sizepto all the edges of the input.Three-element vector
[a b c]of nonnegative integers — Add padding of sizeato the top and bottom, padding of sizebto the left and right, and padding of sizecto the front and back of the input.2-by-3 matrix
[t l f;b r k]of nonnegative integers — Add padding of sizetto the top,bto the bottom,lto the left,rto the right,fto the front, andkto 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).
Step size for traversing the input, specified as one of these:
positive integer
sz— Traverse input with a step size ofszin the vertical, horizontal, and depth dimensions.vector of three positive integers
[a b c]— Traverse input with a vertical step size ofa, a horizontal step size ofb, andcis the step size along the depth dimension.
If the stride dimensions Stride are less than the
respective pooling dimensions, then the pooling regions overlap.
This argument sets the Stride
property.
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.
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Properties
Average Pooling
This property is read-only after object creation. To set this property, use the corresponding
positional input argument when you create the AveragePooling3DLayer
object.
Size of the pooling regions, specified as a vector of three positive integers
[h w d], where h is the height,
w is the width, and d is the depth.
If the stride dimensions Stride are less than the respective
pooling dimensions, then the pooling regions overlap.
Example:
[2 1 1] specifies pooling regions of height 2, width 1, and depth
1.
Step size for traversing the input in three dimensions, specified as a vector
[a b c] of three positive integers, where a is
the vertical step size, b is the horizontal step size, and
c is the step size along the depth direction.
When you set this property, you can also specify a scalar value to use the same value for all dimensions.
If the stride sizes are less than the corresponding pooling window sizes, then the pooling regions overlap.
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.
Data Types: double
Size of padding to apply to input borders, specified as 2-by-3 matrix
[t l f;b r k] of nonnegative
integers, where t and b
are the padding applied to the top and bottom in the vertical
direction, l and r are the
padding applied to the left and right in the horizontal
direction, and f and k are
the padding applied to the front and back along the
depth.
When you create a layer,
use the Padding name-value 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.
Data Types: double
This property is read-only.
Method to determine padding size, represented as one of these:
'manual'– Pad using the integer or vector specified by thePaddingname-value argument.'same'– Apply padding such that the output has the same size as the input for a stride of one. If the stride is larger than 1, then the output size isceil(inputSize/stride), whereinputSizeis the height, width, or depth of the input andstrideis 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.
When you create a layer, use the Padding
name-value argument to specify the method to determine padding size.
Value used to pad input, specified as one of these:
0— Pad the input with zeros.'mean'— Pad the input with the mean of the pooling region.
Specify the padding approach using the Padding name-value
argument.
The layer includes the padded areas when it calculates of the average value of the pooling regions along the edges. Using the mean value as the padding value reduces the effect of the padding values on the calculated average values.
Data Types: double | char
Layer
This property is read-only.
Number of inputs to the layer, represented as 1. This layer has a
single input only.
Data Types: double
This property is read-only.
Input name, represented as {'in'}. This layer has a single input
only.
This property is read-only.
Number of outputs from the layer, represented as 1. This layer has
a single output only.
Data Types: double
This property is read-only.
Output name, represented as {'out'}. This layer has a single output
only.
Examples
Create a 3-D average pooling layer with nonoverlapping pooling regions that downsamples by a factor of 2.
layer = averagePooling3dLayer(2,Stride=2)
layer =
AveragePooling3DLayer with properties:
Name: ''
Hyperparameters
PoolSize: [2 2 2]
Stride: [2 2 2]
PaddingMode: 'manual'
PaddingSize: [2×3 double]
PaddingValue: 0
Include a 3-D average pooling layer in a Layer array.
layers = [ ...
image3dInputLayer([28 28 28 3])
convolution3dLayer(5,20)
reluLayer
averagePooling3dLayer(2,Stride=2)
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 Average Pooling 2×2×2 average pooling with stride [2 2 2] and padding [0 0 0; 0 0 0]
5 '' Fully Connected Fully connected layer with output size 10
6 '' Softmax Softmax
Create a 3-D average pooling layer with overlapping pooling regions and padding for the top and bottom of the input.
layer = averagePooling3dLayer([3 2 2],Stride=2,Padding=[1 0 0])
layer =
AveragePooling3DLayer with properties:
Name: ''
Hyperparameters
PoolSize: [3 2 2]
Stride: [2 2 2]
PaddingMode: 'manual'
PaddingSize: [2×3 double]
PaddingValue: 0
This layer creates pooling regions of size 3-by-2-by-2 and takes the average of the twelve elements in each region. The stride is 2 in all dimensions. The pooling regions overlap because there are stride dimensions Stride that are less than the respective pooling dimensions PoolSize.
Algorithms
A 3-D average pooling layer extends the functionality of an average
pooling layer to a third dimension, depth. An average pooling layer performs down-sampling
by dividing the input into rectangular or cuboidal pooling regions, and computing the
average of each region. To learn more, see the 2-D Average Pooling Layer section of the averagePooling2dLayer 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.
Most 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
functionLayerobjectusing the
forwardandpredictfunctions withdlnetworkobjects
This table shows the supported input formats of AveragePooling3DLayer 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 to
a FunctionLayer 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 of the formats that the layer supports. The
layer might support additional formats, such as formats with additional
"S" (spatial) or "U" (unspecified)
dimensions.
| Input Format | Output Format |
|---|---|
|
|
|
|
|
|
|
|
In dlnetwork objects, AveragePooling3DLayer objects also support
these input and output format combinations.
| Input Format | Output Format |
|---|---|
|
|
|
|
|
|
|
|
|
|
Version History
Introduced in R2019a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)