Evaluate deep learning model for custom training loops
Use dlfeval
to evaluate custom deep learning models for
custom training loops.
Tip
For most deep learning tasks, you can use a pretrained network and adapt it to your own data. For an example showing how to use transfer learning to retrain a convolutional neural network to classify a new set of images, see Train Deep Learning Network to Classify New Images. Alternatively, you can create and train networks from scratch using layerGraph
objects with the trainNetwork
and trainingOptions
functions.
If the trainingOptions
function does not provide the training options that you need for your task, then you can create a custom training loop using automatic differentiation. To learn more, see Define Deep Learning Network for Custom Training Loops.
A dlgradient
call must be inside a function. To obtain a numeric
value of a gradient, you must evaluate the function using dlfeval
,
and the argument to the function must be a dlarray
. See Use Automatic Differentiation In Deep Learning Toolbox.
dlgradient
does not support higher order derivatives. In other
words, you cannot pass the output of a dlgradient
call into another
dlgradient
call.
To enable the correct evaluation of gradients, the function fun
must use only supported functions for dlarray
. See List of Functions with dlarray Support.