Main Content

experiments.Monitor

Update results table and training plots for custom training experiments

    Description

    When running a custom training experiment inExperiment Manager, use anexperiments.Monitorobject to track the progress of the training, update information fields in the results table, record values of the metrics used by the training, and produce training plots. For more information on custom training experiments, seeConfigure Custom Training Experiment.

    Creation

    When you run a custom training experiment, Experiment Manager creates anexperiments.Monitorobject for each trial of your experiment. Access the object as the second input argument of the training function.

    Properties

    expand all

    Training status for a trial, specified as a string or character vector.

    Example:monitor.Status = "Loading Data";

    Data Types:char|string

    Training progress for a trial, specified as a numeric scalar between 0 and 100.

    Example:monitor.Progress = 17;

    Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|fi

    Information column names, specified as a string, character vector, string array, or cell array of character vectors. Valid names begin with a letter, and can contain letters, digits, and underscores. These names appear as column headers in the experiment results table. The values in the information columns do not appear in the training plot.

    You can set this value only once in your training function.

    Example:monitor.Info = ["GradientDecayFactor","SquaredGradientDecayFactor"];

    Data Types:char|string

    Metric column names, specified as a string, character vector, string array, or cell array of character vectors. Valid names begin with a letter, and can contain letters, digits, and underscores. These names appear as column headers in the experiment results table. Additionally, each metric appears in its own training subplot. To plot more than one metric in a single subplot, use the functiongroupSubPlot.

    You can set this value only once in your training function.

    Example:monitor.Metrics = ["TrainingLoss","ValidationLoss"];

    Data Types:char|string

    Horizontal axis label in the training plot, specified as a string or character vector.

    Set this value before calling the functionrecordMetrics.

    Example:monitor.XLabel = "Iteration";

    Data Types:char|string

    This property is read-only.

    Flag to stop trial, specified as a numeric or logical 1 (true) or 0 (false). The value of this property changes totruewhen you click停止in the Experiment Manager toolstrip or the results table.

    Data Types:logical

    Object Functions

    groupSubPlot Group metrics in experiment training plot
    recordMetrics Record metric values in experiment results table and training plot
    updateInfo Update information columns in experiment results table

    Examples

    collapse all

    使用一个experiments.Monitorobject to track the progress of the training, display information and metric values in the experiment results table, and produce training plots for custom training experiments.

    Before starting the training, specify the names of the information and metric columns of the Experiment Manager results table.

    monitor.Info = ["GradientDecayFactor","SquaredGradientDecayFactor"]; monitor.Metrics = ["TrainingLoss","ValidationLoss"];

    Specify the horizontal axis label for the training plot. Group the training and validation loss in the same subplot.

    monitor.XLabel ="Iteration"; groupSubPlot(monitor,"Loss",["TrainingLoss","ValidationLoss"]);

    Update the values of the gradient decay factor and the squared gradient decay factor for the trial in the results table.

    updateInfo(monitor,...GradientDecayFactor=gradientDecayFactor,...SquaredGradientDecayFactor=squaredGradientDecayFactor);

    After each iteration of the custom training loop, record the value of training and validation loss for the trial in the results table and the training plot.

    recordMetrics(monitor,iteration,...TrainingLoss=trainingLoss,...ValidationLoss=validationLoss);

    Update the training progress for the trial based on the fraction of iterations completed.

    monitor.Progress = (iteration/numIterations) * 100;

    Tips

    • Both information and metric columns display values in the results table for your experiment. Additionally, the training plot shows a record of the metric values. Use information columns for text and for numerical values that you want to display in the results table but not in the training plot.

    Introduced in R2021a