save figures and training progress in matlab

To save figures in MATLAB, you can use the saveas function. Here's an example of how to save the current figure as a PNG file:

main.m
saveas(gcf, 'figure.png');
27 chars
2 lines

To save the training progress of a machine learning model, you can use the TrainingPlot property of the training options object. Here's an example:

main.m
options = trainingOptions('sgdm', ...
    'MaxEpochs', 10, ...
    'Plots', 'training-progress');

net = trainNetwork(data, labels, layers, options);

fig = figure;
plotTrainingAccuracy(net.TrainingAccuracy);
saveas(fig, 'accuracy.png');

fig = figure;
plotTrainingLoss(net.TrainingLoss);
saveas(fig, 'loss.png');
314 chars
14 lines

This code saves two figures: accuracy.png and loss.png, which show the training accuracy and loss over epochs, respectively.

gistlibby LogSnag