Main Content

Build Deep Neural Networks

Build networks using command-line functions or interactively using the Deep Network Designer app

Build networks from scratch using MATLAB® code or interactively using the Deep Network Designer app. Use built-in layers to construct networks for tasks such as classification and regression. To see a list of built-in layers, see List of Deep Learning Layers. You can then analyze your network to understand the network architecture and check for problems before training.

If the built-in layers do not provide the layer that you need for your task, then you can define your own custom deep learning layer. You can specify a custom loss function using a custom output layers and define custom layers with or without learnable parameters. After defining a custom layer, you can check that the layer is valid, GPU compatible, and outputs correctly defined gradients.

For models that cannot be specified as networks of layers, you can define the model as a function. For an example showing how to train a deep learning model defined as a function, see Train Network Using Model Function.

Apps

Deep Network DesignerDesign and visualize deep learning networks

Funktionen

alle erweitern

Input Layers

imageInputLayerImage input layer
image3dInputLayer3-D image input layer
sequenceInputLayerSequence input layer
featureInputLayerFeature input layer (Seit R2020b)

Convolution and Fully Connected Layers

convolution2dLayer2-D convolutional layer
convolution3dLayer3-D convolutional layer
groupedConvolution2dLayer2-D grouped convolutional layer
transposedConv2dLayerTransposed 2-D convolution layer
transposedConv3dLayerTransposed 3-D convolution layer
fullyConnectedLayerFully connected layer

Recurrent Layers

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) (Seit R2020a)
lstmProjectedLayerLong short-term memory (LSTM) projected layer for recurrent neural network (RNN) (Seit R2022b)
gruProjectedLayerGated recurrent unit (GRU) projected layer for recurrent neural network (RNN) (Seit R2023b)

Transformer Layers

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

Neural ODE Layers

neuralODELayerNeural ODE layer (Seit R2023b)

Activation Layers

reluLayerRectified Linear Unit (ReLU) layer
leakyReluLayerLeaky Rectified Linear Unit (ReLU) layer
preluLayerParametrized Rectified Linear Unit (PReLU) layer (Seit R2024a)
clippedReluLayerClipped Rectified Linear Unit (ReLU) layer
eluLayerExponential linear unit (ELU) layer
tanhLayerHyperbolic tangent (tanh) layer
swishLayerSwish layer (Seit R2021a)
geluLayerGaussian error linear unit (GELU) layer (Seit R2022b)
softmaxLayerSoftmax layer
sigmoidLayerSigmoid layer (Seit R2020b)
functionLayerFunction layer (Seit R2021b)

Normalization Layers

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

Utility Layers

dropoutLayerDropout layer
crop2dLayer2-D crop layer
crop3dLayer3-D crop layer (Seit R2019b)
networkLayerNetwork Layer (Seit R2024a)

Data Manipulation

sequenceFoldingLayer(Not recommended) Sequence folding layer
sequenceUnfoldingLayer(Not recommended) Sequence unfolding layer
flattenLayerFlatten layer

Pooling and Unpooling Layers

averagePooling2dLayerAverage pooling layer
averagePooling3dLayer3-D average pooling layer
globalAveragePooling2dLayer2-D global average pooling layer (Seit R2019b)
globalAveragePooling3dLayer3-D global average pooling layer (Seit R2019b)
globalMaxPooling2dLayerGlobal max pooling layer (Seit R2020a)
globalMaxPooling3dLayer3-D global max pooling layer (Seit R2020a)
maxPooling2dLayerMax pooling layer
maxPooling3dLayer3-D max pooling layer
maxUnpooling2dLayerMax unpooling layer

Combination Layers

additionLayerAddition layer
multiplicationLayerMultiplication layer (Seit R2020b)
concatenationLayerConcatenation layer
depthConcatenationLayerDepth concatenation layer
dlnetworkDeep learning neural network (Seit R2019b)
imagePretrainedNetworkPretrained neural network for images (Seit R2024a)
resnetNetwork2-D residual neural network (Seit R2024a)
resnet3dNetwork3-D residual neural network (Seit R2024a)
addLayersAdd layers to neural network
removeLayersRemove layers from neural network
replaceLayerReplace layer in neural network
getLayerLook up a layer by name or path (Seit R2024a)
connectLayersConnect layers in neural network
disconnectLayersDisconnect layers in neural network
expandLayersExpand network layers (Seit R2024a)
groupLayersGroup layers into network layers (Seit R2024a)
analyzeNetworkAnalyze deep learning network architecture
addInputLayerAdd input layer to network (Seit R2022b)
initializeInitialize learnable and state parameters of a dlnetwork (Seit R2021a)
networkDataLayoutDeep learning network data layout for learnable parameter initialization (Seit 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
dag2dlnetworkConvert SeriesNetwork and DAGNetwork to dlnetwork (Seit R2024a)
plotPlot neural network architecture
summaryPrint network summary (Seit R2022b)
analyzeNetworkAnalyze deep learning network architecture
checkLayerCheck validity of custom or function layer
isequalCheck equality of neural networks (Seit R2021a)
isequalnCheck equality of neural networks ignoring NaN values (Seit R2021a)

Themen

Built-In Layers

Custom Layers