Main Content

Build Deep Neural Networks

Build neural networks for image data using MATLAB® code or interactively using Deep Network Designer

Create new deep networks for tasks such as image classification and regression by defining the network architecture from scratch. Build networks using MATLAB or interactively using Deep Network Designer.

For most tasks, you can use built-in layers. If there is not a built-in layer that you need for your task, then you can define your own custom layer. You can specify a custom loss function using a custom output layer and define custom layers with learnable and state parameters. After defining a custom layer, you can check that the layer is valid, GPU compatible, and outputs correctly defined gradients. For a list of supported layers, see List of Deep Learning Layers.

For models that layer graphs do not support, you can define a custom model as a function. To learn more, see Define Custom Training Loops, Loss Functions, and Networks.


Deep Network DesignerDesign, visualize, and train deep learning networks


alle erweitern

Input Layers

imageInputLayerImage input layer
image3dInputLayer3-D image input layer (Seit R2019a)

Convolution and Fully Connected Layers

convolution2dLayer2-D convolutional layer
convolution3dLayer3-D convolutional layer (Seit R2019a)
groupedConvolution2dLayer2-D grouped convolutional layer (Seit R2019a)
transposedConv2dLayerTransposed 2-D convolution layer
transposedConv3dLayerTransposed 3-D convolution layer (Seit R2019a)
fullyConnectedLayerFully connected layer

Transformer Layers

selfAttentionLayerSelf-attention layer (Seit R2023a)
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
clippedReluLayerClipped Rectified Linear Unit (ReLU) layer
eluLayerExponential linear unit (ELU) layer (Seit R2019a)
tanhLayerHyperbolic tangent (tanh) layer (Seit R2019a)
swishLayerSwish layer (Seit R2021a)
geluLayerGaussian error linear unit (GELU) layer (Seit R2022b)
sigmoidLayerSigmoid layer (Seit R2020b)
softmaxLayerSoftmax layer
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)

Pooling and Unpooling Layers

averagePooling2dLayerAverage pooling layer
averagePooling3dLayer3-D average pooling layer (Seit R2019a)
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 (Seit R2019a)
maxUnpooling2dLayerMax unpooling layer

Combination Layers

additionLayerAddition layer
multiplicationLayerMultiplication layer (Seit R2020b)
concatenationLayerConcatenation layer (Seit R2019a)
depthConcatenationLayerDepth concatenation layer

Output Layers

classificationLayerClassification output layer
regressionLayerRegression output layer
layerGraphGraph of network layers for deep learning
plotPlot neural network architecture
addLayersAdd layers to layer graph or network
removeLayersRemove layers from layer graph or network
replaceLayerReplace layer in layer graph or network
connectLayersConnect layers in layer graph or network
disconnectLayersDisconnect layers in layer graph or network
DAGNetworkDirected acyclic graph (DAG) network for deep learning
resnetLayersCreate 2-D residual network (Seit R2021b)
resnet3dLayersCreate 3-D residual network (Seit R2021b)
isequalCheck equality of deep learning layer graphs or networks (Seit R2021a)
isequalnCheck equality of deep learning layer graphs or networks ignoring NaN values (Seit R2021a)
analyzeNetworkAnalyze deep learning network architecture
dlnetworkDeep learning network for custom training loops (Seit R2019b)
addInputLayerAdd input layer to network (Seit R2022b)
summaryPrint network summary (Seit R2022b)
initializeInitialize learnable and state parameters of a dlnetwork (Seit R2021a)
networkDataLayoutDeep learning network data layout for learnable parameter initialization (Seit R2022b)
checkLayerCheck validity of custom or function layer


Built-In Layers

Custom Layers