Main Content

操作

开发自定义深度学习函数

对于大多数任务,您可以使用内置层。如果没有您的任务所需的内置层,则可以定义您自己的自定义层。您可以定义具有可学习参数和状态参数的自定义层。定义自定义层后,您可以检查该层是否有效,是否与 GPU 兼容,以及是否输出正确定义的梯度。要了解详细信息,请参阅定义自定义深度学习层。要查看支持的层的列表,请参阅深度学习层列表

如果 trainingOptions 函数不提供任务所需的训练选项,或您有 trainnet 函数不支持的损失函数,您可以定义自定义训练循环。对于无法指定为由层组成的网络的模型,可以将模型定义为函数。要了解详细信息,请参阅定义自定义训练循环、损失函数和网络

使用深度学习运算为自定义层、训练循环和模型函数开发 MATLAB® 代码。

函数

全部展开

dlarray用于自定义的深度学习数组
dimsdlarray 对象的数据格式
finddimFind dimensions with specified label
stripdimsRemove dlarray data format
extractdatadlarray 中提取数据
isdlarrayCheck if object is dlarray (自 R2020b 起)
dlconvDeep learning convolution
dltranspconvDeep learning transposed convolution
lstmLong short-term memory
gruGated recurrent unit (自 R2020a 起)
attentionDot-product attention (自 R2022b 起)
embedEmbed discrete data (自 R2020b 起)
fullyconnectSum all weighted input data and apply a bias
dlode45Deep learning solution of nonstiff ordinary differential equation (ODE) (自 R2021b 起)
batchnormNormalize data across all observations for each channel independently
crosschannelnormCross channel square-normalize using local responses (自 R2020a 起)
groupnormNormalize data across grouped subsets of channels for each observation independently (自 R2020b 起)
instancenormNormalize across each channel for each observation independently (自 R2021a 起)
layernormNormalize data across all channels for each observation independently (自 R2021a 起)
avgpoolPool data to average values over spatial dimensions
maxpoolPool data to maximum value
maxunpoolUnpool the output of a maximum pooling operation
relu应用修正线性单元激活
leakyreluApply leaky rectified linear unit activation
geluApply Gaussian error linear unit (GELU) activation (自 R2022b 起)
softmaxApply softmax activation to channel dimension
sigmoid应用 sigmoid 激活
crossentropyCross-entropy loss for classification tasks
indexcrossentropyIndex cross-entropy loss for classification tasks (自 R2024b 起)
l1lossL1 loss for regression tasks (自 R2021b 起)
l2lossL2 loss for regression tasks (自 R2021b 起)
huberHuber loss for regression tasks (自 R2021a 起)
ctcConnectionist temporal classification (CTC) loss for unaligned sequence classification (自 R2021a 起)
mseHalf mean squared error
dlaccelerateAccelerate deep learning function for custom training loops (自 R2021a 起)
AcceleratedFunctionAccelerated deep learning function (自 R2021a 起)
clearCacheClear accelerated deep learning function trace cache (自 R2021a 起)

主题

自动微分

模型函数

深度学习函数加速

精选示例