Main Content

本页的翻译已过时。点击此处可查看最新英文版本。

深度学习自定义层

为深度学习定义自定义层

您可以针对您的问题定义自己的自定义深度学习层。您可以使用自定义输出层指定自定义损失函数,并定义具有或不具有可学习参数的自定义层。定义自定义层后,您可以检查该层是否有效,是否与 GPU 兼容,以及是否输出正确定义的梯度。

函数

全部展开

checkLayerCheck validity of custom or function layer
setLearnRateFactorSet learn rate factor of layer learnable parameter
setL2FactorSet L2 regularization factor of layer learnable parameter
getLearnRateFactorGet learn rate factor of layer learnable parameter
getL2FactorGet L2 regularization factor of layer learnable parameter
findPlaceholderLayersFind placeholder layers in network architecture imported from Keras or ONNX
replaceLayerReplace layer in layer graph
assembleNetworkAssemble deep learning network from pretrained layers
PlaceholderLayerLayer replacing an unsupported Keras or ONNX layer, or unsupported functionality from functionToLayerGraph

主题

自定义中间层

定义自定义深度学习层

了解如何定义自定义深度学习层。

Define Custom Deep Learning Layer with Learnable Parameters

This example shows how to define a PReLU layer and use it in a convolutional neural network.

Define Custom Deep Learning Layer with Multiple Inputs

This example shows how to define a custom weighted addition layer and use it in a convolutional neural network.

Define Custom Deep Learning Layer with Formatted Inputs

This example shows how to define a custom layer with formatted dlarray inputs.

Specify Custom Layer Backward Function

This example shows how to define a PReLU layer and specify a custom backward function.

Define Custom Deep Learning Layer for Code Generation

This example shows how to define a PReLU layer that supports code generation.

自定义输出层

Define Custom Classification Output Layer

This example shows how to define a custom classification output layer with sum of squares error (SSE) loss and use it in a convolutional neural network.

Define Custom Regression Output Layer

This example shows how to define a custom regression output layer with mean absolute error (MAE) loss and use it in a convolutional neural network.

Specify Custom Output Layer Backward Loss Function

This example shows how to define a custom classification output layer with sum of squares error (SSE) loss and specify a custom backward loss function.

网络合成和嵌套层

Deep Learning Network Composition

Define custom layers containing layer graphs.

Define Nested Deep Learning Layer

This example shows how to define a nested deep learning layer.

Train Deep Learning Network with Nested Layers

This example shows how to train a network with nested layers.

检查层有效性

Check Custom Layer Validity

Learn how to check the validity of custom deep learning layers.