Main Content

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

深度学习自定义训练循环

自定义深度学习训练循环和损失函数

如果 trainingOptions 函数不提供任务所需的训练选项,或者自定义输出层不支持所需的损失函数,则您可以定义自定义训练循环。对于无法使用层次图创建的网络,可以将自定义网络定义为函数。要了解详细信息,请参阅定义自定义训练循环、损失函数和网络

函数

全部展开

dlnetworkDeep learning network for custom training loops
forwardCompute deep learning network output for training
predictCompute deep learning network output for inference
adamupdateUpdate parameters using adaptive moment estimation (Adam)
rmspropupdate Update parameters using root mean squared propagation (RMSProp)
sgdmupdate Update parameters using stochastic gradient descent with momentum (SGDM)
dlupdate Update parameters using custom function
minibatchqueueCreate mini-batches for deep learning
onehotencodeEncode data labels into one-hot vectors
onehotdecodeDecode probability vectors into class labels
dlarrayDeep learning array for custom training loops
dlgradientCompute gradients for custom training loops using automatic differentiation
dlfevalEvaluate deep learning model for custom training loops
dimsDimension labels of dlarray
finddimFind dimensions with specified label
stripdimsRemove dlarray labels
extractdataExtract data from dlarray
isdlarrayDetermine whether input is dlarray
functionToLayerGraphConvert deep learning model function to a layer graph
dlconvDeep learning convolution
dltranspconvDeep learning transposed convolution
lstmLong short-term memory
gruGated recurrent unit
embedEmbed discrete data
fullyconnectSum all weighted input data and apply a bias
reluApply rectified linear unit activation
leakyreluApply leaky rectified linear unit activation
batchnormNormalize across all observations for each channel independently
crosschannelnormCross channel square-normalize using local responses
groupnormNormalize across grouped subsets of channels for each observation independently
avgpoolPool data to average values over spatial dimensions
maxpoolPool data to maximum value
maxunpoolUnpool the output of a maximum pooling operation
softmaxApply softmax activation to channel dimension
crossentropyCross-entropy loss for classification tasks
sigmoidApply sigmoid activation
mseHalf mean squared error

主题

自定义训练循环

Train Deep Learning Model in MATLAB

Learn how to training deep learning models in MATLAB®.

定义自定义训练循环、损失函数和网络

了解如何使用自动微分来定义和自定义深度学习训练循环、损失函数和网络。

Train Network Using Custom Training Loop

This example shows how to train a network that classifies handwritten digits with a custom learning rate schedule.

Specify Training Options in Custom Training Loop

Learn how to specify common training options in a custom training loop.

Define Model Gradients Function for Custom Training Loop

Learn how to define a model gradients function for a custom training loop.

Update Batch Normalization Statistics in Custom Training Loop

This example shows how to update the network state in a custom training loop.

Make Predictions Using dlnetwork Object

This example shows how to make predictions using a dlnetwork object by splitting data into mini-batches.

Train Network on Image and Feature Data

This example shows how to train a network that classifies handwritten digits using both image and feature input data.

Train Network with Multiple Outputs

This example shows how to train a deep learning network with multiple outputs that predict both labels and angles of rotations of handwritten digits.

模型函数

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 a dlnetwork.

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.

自动微分

List of Functions with dlarray Support

View the list of functions that support dlarray objects.

Automatic Differentiation Background

Learn how automatic differentiation works.

Use Automatic Differentiation In Deep Learning Toolbox

How to use automatic differentiation in deep learning.

特色示例