主要内容

globalAveragePooling3dLayer

3-D全局平均池化层

Description

A 3-D global average pooling layer performs downsampling by computing the mean of the height, width, and depth dimensions of the input.

Creation

Description

layer= globalAveragePooling3dLayercreates a 3-D global average pooling layer.

example

layer= globalAveragePooling3dLayer('Name',name)sets the optionalNameproperty.

Properties

expand all

图层名称,指定为字符向量或字符串标量。为了Layerarray input, thetrainNetwork,汇编,分层图, 和dlnetwork函数自动将名称分配给图层Nameset to''.

Data Types:char|string

This property is read-only.

图层的输入数。此图层仅接受单个输入。

Data Types:double

This property is read-only.

Input names of the layer. This layer accepts a single input only.

Data Types:cell

This property is read-only.

Number of outputs of the layer. This layer has a single output only.

Data Types:double

This property is read-only.

图层的输出名称。此图层仅具有单个输出。

Data Types:cell

Examples

collapse all

使用名称创建一个三维全局平均水平池层'GAP1'.

layer = globalAveragePooling3dLayer('Name','GAP1')
layer = GlobalAveragePooling3DLayer with properties: Name: 'gap1'

Include a 3-D global average pooling layer in aLayerarray.

layers = [...image3dInputLayer([28 28 28 3]) convolution3dLayer(5,20) reluLayer globalAveragePooling3dLayer 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 Global Average Pooling 3-D global average pooling 5 '' Fully Connected 10 fully connected layer 6 '' Softmax softmax 7 '' Classification Output crossentropyex

Tips

  • In an image classification network, you can use aglobalAveragePooling3dLayerbefore 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 aglobalAveragePooling3dLayertowards the end of a classification network instead of afullyConnectedLayer. 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 aglobalmaxpooling3dlayer.instead. Whether aglobalmaxpooling3dlayer.or aglobalAveragePooling3dLayer更合适取决于您的数据集。

    要使用全局平均池代替完全连接的层,输入的大小globalAveragePooling3dLayermust match the number of classes in the classification problem

Introduced in R2019b