Main Content

构建深度神经网络

使用 MATLAB® 代码或以交互方式使用深度网络设计器为序列和表格数据构建网络

通过从头开始定义网络架构,为分类、回归和预测等任务创建新的深度网络。使用 MATLAB 或以交互方式使用深度网络设计器构建网络。

对于大多数任务,您可以使用内置层。如果没有您的任务所需的内置层,则可以定义您自己的自定义层。您可以定义具有可学习参数和状态参数的自定义层。定义自定义层后,您可以检查该层是否有效,是否与 GPU 兼容,以及是否输出正确定义的梯度。要查看支持的层的列表,请参阅深度学习层列表

对于无法指定为由层组成的网络的模型,可以将模型定义为函数。要了解详细信息,请参阅定义自定义训练循环、损失函数和网络

App

深度网络设计器设计和可视化深度学习网络

函数

全部展开

输入层

sequenceInputLayerSequence input layer
featureInputLayerFeature input layer (自 R2020b 起)

循环层

lstmLayerLong short-term memory (LSTM) layer for recurrent neural network (RNN)
bilstmLayerBidirectional long short-term memory (BiLSTM) layer for recurrent neural network (RNN)
gruLayerGated recurrent unit (GRU) layer for recurrent neural network (RNN) (自 R2020a 起)
lstmProjectedLayerLong short-term memory (LSTM) projected layer for recurrent neural network (RNN) (自 R2022b 起)
gruProjectedLayerGated recurrent unit (GRU) projected layer for recurrent neural network (RNN) (自 R2023b 起)

变换器层

selfAttentionLayerSelf-attention layer (自 R2023a 起)
attentionLayerDot-product attention layer (自 R2024a 起)
positionEmbeddingLayerPosition embedding layer (自 R2023b 起)
sinusoidalPositionEncodingLayerSinusoidal position encoding layer (自 R2023b 起)
embeddingConcatenationLayerEmbedding concatenation layer (自 R2023b 起)
indexing1dLayer1-D indexing layer (自 R2023b 起)

神经 ODE 层

neuralODELayerNeural ODE layer (自 R2023b 起)

卷积和全连接层

convolution1dLayer1-D convolutional layer (自 R2021b 起)
transposedConv1dLayerTransposed 1-D convolution layer (自 R2022a 起)
fullyConnectedLayerFully connected layer

激活层和丢弃层

reluLayer修正线性单元 (ReLU) 层
leakyReluLayerLeaky Rectified Linear Unit (ReLU) layer
preluLayerParametrized Rectified Linear Unit (PReLU) layer (自 R2024a 起)
clippedReluLayerClipped Rectified Linear Unit (ReLU) layer
eluLayerExponential linear unit (ELU) layer
tanhLayer双曲正切 (tanh) 层
swishLayerSwish layer (自 R2021a 起)
geluLayerGaussian error linear unit (GELU) layer (自 R2022b 起)
sigmoidLayerSigmoid layer (自 R2020b 起)
softmaxLayerSoftmax 层
dropoutLayer丢弃层
spatialDropoutLayerSpatial dropout layer (自 R2024a 起)
functionLayerFunction layer (自 R2021b 起)

归一化层

batchNormalizationLayerBatch normalization layer
groupNormalizationLayerGroup normalization layer (自 R2020b 起)
instanceNormalizationLayerInstance normalization layer (自 R2021a 起)
layerNormalizationLayerLayer normalization layer (自 R2021a 起)
crossChannelNormalizationLayer Channel-wise local response normalization layer

池化层

maxPooling1dLayer1-D max pooling layer (自 R2021b 起)
averagePooling1dLayer1-D average pooling layer (自 R2021b 起)
globalMaxPooling1dLayer1-D global max pooling layer (自 R2021b 起)
globalAveragePooling1dLayer1-D global average pooling layer (自 R2021b 起)
adaptiveAveragePooling2dLayerAdaptive average pooling 2-D layer (自 R2024a 起)

组合层

additionLayerAddition layer
multiplicationLayerMultiplication layer (自 R2020b 起)
concatenationLayerConcatenation layer
depthConcatenationLayerDepth concatenation layer
dlnetworkDeep learning neural network (自 R2019b 起)
addLayersAdd layers to neural network
removeLayersRemove layers from neural network
replaceLayerReplace layer in neural network
connectLayersConnect layers in neural network
disconnectLayersDisconnect layers in neural network
addInputLayerAdd input layer to network (自 R2022b 起)
initializeInitialize learnable and state parameters of a dlnetwork (自 R2021a 起)
networkLayerNetwork Layer (自 R2024a 起)
expandLayersExpand network layers (自 R2024a 起)
groupLayersGroup layers into network layers (自 R2024a 起)
networkDataLayoutDeep learning network data layout for learnable parameter initialization (自 R2022b 起)
setL2FactorSet L2 regularization factor of layer learnable parameter
getL2FactorGet L2 regularization factor of layer learnable parameter
setLearnRateFactorSet learn rate factor of layer learnable parameter
getLearnRateFactorGet learn rate factor of layer learnable parameter
plot绘制神经网络架构
summary打印网络摘要 (自 R2022b 起)
analyzeNetworkAnalyze deep learning network architecture
checkLayerCheck validity of custom or function layer
isequalCheck equality of neural networks (自 R2021a 起)
isequalnCheck equality of neural networks ignoring NaN values (自 R2021a 起)

主题

内置层

自定义层