Debug Deep Learning Experiments - MATLAB & Simulink (original) (raw)

In Experiment Manager, you use MATLAB® functions to configure the training data, network architecture, and training options, specify the training procedure, and evaluate the results of your deep learning experiment. You can diagnose problems in these functions by stepping through your code line-by-line and examining the values of your variables.

Start Debugging Session

You can debug your code before or after you run the experiment.

To debug your code before you run the experiment:

  1. Open the experiment.
  2. In the Experiment Manager toolstrip, select > .
  3. In dialog box, specify the hyperparameter values for your experiment.
  4. Click Start.

To debug your code after you run the experiment:

  1. Open the results for the experiment.
  2. In the results table, select a trial to debug. To ensure reproducibility,Experiment Manager reuses the hyperparameter values and the random seed saved for this trial.
  3. Right-click the trial and select Debug .

Experiment Manager opens the setup or training function in MATLAB Editor, places a breakpoint in the first line of code, and runs the function.

Experiment Manager sets a breakpoint on the first line of code in your setup or training function.

Verify Your Results

After your function runs to completion, verify your results by examining the hyperparameters and output values stored in the workspace variables

where functionName is the name of the setup or training function.

Debug Metric Functions

After you debug the setup function for a built-in training experiment, you can inspect the training data and training options in the MATLAB Workspace browser or visualize the network layers in the Deep Network Designer app. You can also call the built-in training function trainNetwork and step through your metric functions:

  1. In the MATLAB Command Window, call trainNetwork using the output of your setup function. For example, if your setup function is calledRegressionExperiment_setup, enter:
    [tNet,tInfo] = trainNetwork(RegressionExperiment_setup_output{:});
  2. Create a structure called trialInfo that contains the fieldstrainedNetwork, trainingInfo, andparameters. For values, use the outputs of thetrainNetwork function and the hyperparameters used for training. For example, if your setup function is calledRegressionExperiment_setup, enter:
    trialInfo = struct(trainedNetwork=tNet, ...
    trainingInfo=tInfo, ...
    parameters=RegressionExperiment_setup_params);
  3. In Experiment Manager, in the experiment definition tab, underMetrics, select the name of a metric function and clickEdit. The metric function opens in MATLAB Editor.
  4. In the metric function, set breakpoints as described in Set Breakpoints.
    Set a breakpoint on a line of code in the metric function.
  5. In the MATLAB Command Window, call the metric function using thetrialInfo structure as the input to the function. For example, if your metric function is called Accuracy, enter:
    metricOutput = Accuracy(trialInfo)
    MATLAB pauses at each line of code that has a breakpoint. When the function execution stops at the breakpoint, you can view the values of your variables, step through the code line-by-line, or continue to the next breakpoint. After the function runs to completion, examine the output value. The output must be a scalar number, a logical value, or a string.

See Also

Apps

Functions

Objects