Azzera filtri
Azzera filtri

Save training progress plots using OutputFcn

5 visualizzazioni (ultimi 30 giorni)
FEDERICO FURLAN
FEDERICO FURLAN il 18 Lug 2019
Commentato: M J il 5 Ott 2020
Hi,
I'm trying to save the training progress plots using the OutputFcn training option as written in a previous question:
I'm using Matlab v.2018b and that solution doesn't work, this is the code that I'm using in a live script:
options = trainingOptions('sgdm',...
'InitialLearnRate',0.003,...
'Plots','training-progress', ...
'ValidationData',garVal,...
'ValidationFrequency',40,...
'MaxEpochs',1,...
'LearnRateSchedule', 'piecewise',...
'LearnRateDropPeriod',3,...
'Shuffle','every-epoch',...
'ValidationPatience',5,...
'OutputFcn',@(info)SaveTrainingPlot(info),...
'Verbose',true);
% ... Training code ...
% At the end of the script:
function stop = SaveTrainingPlot(info)
stop = false;
if info.State == "done"
currentfig = findall(groot,'Type','Figure');
savefig(currentfig,'prova.png')
end
end
At the end of the training this error appears:
Error using trainNetwork (line 150)
Functionality not supported with figures created with the uifigure function. For more information, see Graphics Support in App Designer.
The problem seems to be the function savefig (and also saveas has the same problem)... and, if I use gcf instead of groot inside savefig, a blanck picture is saved.
How can I solve the problem? Is there an other way to save the training progress plots?
Thanks!

Risposte (1)

Bhargavi Maganuru
Bhargavi Maganuru il 5 Ago 2019
“savefig” accepts ‘.fig’ file extension only. It does not accepts other file extensions. For more information see the “input Arguments” section in the below MATLAB documentation.
Whereas “saveas” function accepts ‘.png’,’.fig’ and many other file extensions. For more information see the “input Arguments” section in the below MATLAB documentation.
Hope this helps.
  1 Commento
M J
M J il 5 Ott 2020
Hi, can I use the OutputFcn to add any function I created (in my case : a function that processes the image datastore in a specific way)? Thank you!

Accedi per commentare.

Prodotti


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by