groupSubPlot
Description
groupSubPlot(
groups the specified metrics in a single training subplot with the y-axis
label monitor
,groupName
,metricNames
)groupName
. By default, the software plots each ungrouped metric
in its own training subplot.
To group metrics, all metrics must have the same y-axis scale. For more information, see
yscale
.
Examples
Track Progress and Produce Training Plots
Use a TrainingProgressMonitor
object to track training progress and produce training plots for custom training loops.
Create a TrainingProgressMonitor
object. The monitor automatically tracks the start time and the elapsed time. The timer starts when you create the object.
Tip
To ensure that the elapsed time accurately reflects the training time, make sure you create the TrainingProgressMonitor
object close to the start of your custom training loop.
monitor = trainingProgressMonitor;
Before you start the training, specify names for the information and metric values.
monitor.Info = ["LearningRate","Epoch","Iteration"]; monitor.Metrics = ["TrainingLoss","ValidationLoss","TrainingAccuracy","ValidationAccuracy"];
Specify the horizontal axis label for the training plot. Group the training and validation loss in the same subplot. Group the training and validation accuracy in the same plot.
monitor.XLabel = "Iteration"; groupSubPlot(monitor,"Loss",["TrainingLoss","ValidationLoss"]); groupSubPlot(monitor,"Accuracy",["TrainingAccuracy","ValidationAccuracy"]);
Specify a logarithmic scale for the loss. You can also switch the y-axis scale by clicking the log scale button in the axes toolbar.
yscale(monitor,"Loss","log")
During training:
Evaluate the
Stop
property at the start of each step in your custom training loop. When you click the Stop button in the Training Progress window, theStop
property changes to1
. Training stops if your training loop exits when theStop
property is1
.Update the information values. The updated values appear in the Training Progress window.
Record the metric values. The recorded values appear in the training plot.
Update the training progress percentage based on the fraction of iterations completed.
Note
The following example code is a template. You must edit this training loop to compute your metric and information values. For a complete example that you can run in MATLAB, see Monitor Custom Training Loop Progress During Training.
epoch = 0; iteration = 0; monitor.Status = "Running"; while epoch < maxEpochs && ~monitor.Stop epoch = epoch + 1; while hasData(mbq) && ~monitor.Stop iteration = iteration + 1; % Add code to calculate metric and information values. % lossTrain = ... updateInfo(monitor, ... LearningRate=learnRate, ... Epoch=string(epoch) + " of " + string(maxEpochs), ... Iteration=string(iteration) + " of " + string(numIterations)); recordMetrics(monitor,iteration, ... TrainingLoss=lossTrain, ... TrainingAccuracy=accuracyTrain, ... ValidationLoss=lossValidation, ... ValidationAccuracy=accuracyValidation); monitor.Progress = 100*iteration/numIterations; end end
The Training Progress window shows animated plots of the metrics, as well as the information values, training progress bar, and elapsed time.
The training plots update each time you call
recordMetrics
.The values under Information update each time you call
updateInfo
.The elapsed time updates each time you call
recordMetrics
orupdateInfo
and when you update the Progress property.
Input Arguments
monitor
— Training progress monitor
TrainingProgressMonitor
object
Training progress monitor, specified as a TrainingProgressMonitor
object.
groupName
— Name of subplot group
string scalar | character vector
Name of the subplot group, specified as a string scalar or character vector. The
software groups the specified metrics in a single training subplot with the
y-axis label groupName
.
Data Types: char
| string
metricNames
— Metric names
string scalar | character vector | string array | cell array of character vectors
Version History
Introduced in R2022b
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)