操作
开发自定义深度学习函数
对于大多数任务,您可以使用内置层。如果没有您的任务所需的内置层,则可以定义您自己的自定义层。您可以定义具有可学习参数和状态参数的自定义层。定义自定义层后,您可以检查该层是否有效,是否与 GPU 兼容,以及是否输出正确定义的梯度。要了解详细信息,请参阅定义自定义深度学习层。要查看支持的层的列表,请参阅深度学习层列表。
如果 trainingOptions
函数不提供任务所需的训练选项,或您有 trainnet
函数不支持的损失函数,您可以定义自定义训练循环。对于无法指定为由层组成的网络的模型,可以将模型定义为函数。要了解详细信息,请参阅定义自定义训练循环、损失函数和网络。
使用深度学习运算为自定义层、训练循环和模型函数开发 MATLAB® 代码。
函数
主题
自动微分
- List of Functions with dlarray Support
View the list of functions that supportdlarray
objects. - Automatic Differentiation Background
Learn how automatic differentiation works. - Use Automatic Differentiation In Deep Learning Toolbox
How to use automatic differentiation in deep learning. - Define Custom Deep Learning Operations
Learn how to define custom deep learning operation. - Specify Custom Operation Backward Function
This example shows how to define the SReLU operation as a differentiable function and specify a custom backward function. - Train Model Using Custom Backward Function
This example shows how to train a deep learning model that contains an operation with a custom backward function.
模型函数
- Train Network Using Model Function
This example shows how to create and train a deep learning network by using functions rather than a layer graph or adlnetwork
. - Update Batch Normalization Statistics Using Model Function
This example shows how to update the network state in a network defined as a function. - Make Predictions Using Model Function
This example shows how to make predictions using a model function by splitting data into mini-batches. - Initialize Learnable Parameters for Model Function
Learn how to initialize learnable parameters for custom training loops using a model function.
深度学习函数加速
- Deep Learning Function Acceleration for Custom Training Loops
Accelerate model functions and model loss functions for custom training loops by caching and reusing traces. - Accelerate Custom Training Loop Functions
This example shows how to accelerate deep learning custom training loop and prediction functions. - Check Accelerated Deep Learning Function Outputs
This example shows how to check that the outputs of accelerated functions match the outputs of the underlying function. - Evaluate Performance of Accelerated Deep Learning Function
This example shows how to evaluate the performance gains of using an accelerated function.