Save training progress plots using OutputFcn

9 次查看(过去 30 天)
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
“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 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by