自定义层
为深度学习定义自定义层
对于大多数任务,您可以使用内置层。如果没有您的任务所需的内置层,则可以定义您自己的自定义层。您可以使用自定义输出层指定自定义损失函数,并定义具有可学习参数和状态参数的自定义层。定义自定义层后,您可以检查该层是否有效,是否与 GPU 兼容,以及是否输出正确定义的梯度。要查看支持的层的列表,请参阅深度学习层列表。
函数
主题
自定义层概述
- 定义自定义深度学习层
了解如何定义自定义深度学习层。 - Define Custom Deep Learning Intermediate Layers
Learn how to define custom deep learning intermediate layers. - Define Custom Deep Learning Output Layers
Learn how to define custom deep learning output layers. - Check Custom Layer Validity
Learn how to check the validity of custom deep learning layers. - Import Custom Layer into Deep Network Designer
This example shows how to import a custom classification output layer with the sum of squares error (SSE) loss and add it to a pretrained network in Deep Network Designer. - 基于预训练的 Keras 层组合网络
此示例说明如何从预训练的 Keras 网络中导入层、用自定义层替换不支持的层,以及将各层组合成可以进行预测的网络。 - Replace Unsupported Keras Layer with Function Layer
This example shows how to import the layers from a pretrained Keras network, replace the unsupported layers with function layers, and assemble the layers into a network ready for prediction.
自定义中间层
- 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 formatteddlarray
inputs. - Define Custom Recurrent Deep Learning Layer
This example shows how to define a peephole LSTM layer and use it in a neural network. - Specify Custom Layer Backward Function
This example shows how to define a PReLU layer and specify a custom backward function. - Custom Layer Function Acceleration
Accelerate custom layer forward and predict functions by caching and reusing traces. - 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.