Save training progress plots using OutputFcn

조회 수: 6 (최근 30일)
FEDERICO FURLAN
FEDERICO FURLAN 2019년 7월 18일
댓글: M J 2020년 10월 5일
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!

답변 (1개)

Bhargavi Maganuru
Bhargavi Maganuru 2019년 8월 5일
“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
M J
M J 2020년 10월 5일
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!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by