For the trainNetwork function, progress plots for training are not closing, except if done manually. How do I close it? I have tried close all, close force, close(fig), & more
3 次查看(过去 30 天)
显示 更早的评论
Please only answer if you have tried to use trainNetwork with the same plot below, and the answer works for that in Matlab 2023a and Matlab2023b as this seems to be a special case where the close function does not work as normal, and more. I have tried many things and other things. Below is the code.
options = trainingOptions('adam', ...
'InitialLearnRate',0.002, ...
'LearnRateSchedule','piecewise',...
'LearnRateDropPeriod',1000, ...
'LearnRateDropFactor',0.75,...
'MiniBatchSize',40,...
'Shuffle','every-epoch', ...
'MaxEpochs',7000, ...
'Verbose',false, ...
'Plots','training-progress', ...
'ExecutionEnvironment','gpu');
%MaxEpochs was 7000,
[net, info] = trainNetwork(trainEps,trainH,layers,options);
currentfig = findall(groot,'Tag','NNET_CNN_TRAININGPLOT_UIFIGURE');
save([namedd2],...
"net","cmlSz","test","lblTrain","ulTrain",...
"cmlPref","cmlMed","cmlSuf","info")
close all
clear trainEps
2 个评论
Matt J
2025-7-8
Please only answer if you have tried to use trainNetwork with the same plot below,
How would we? The training data has not been provided. Anyway, I doubt you'll find a solution here if close force is only failing for one particular example. Tech Support will have to be involved.
Joss Knight
2025-7-18
The training plot is an app, not a figure, so can't be closed or managed using figure commands. I'll find a workaround for you.
回答(1 个)
Matt J
2025-7-8
Try resetting your GPU.
gpu = gpuDevice;
reset(gpu);
close all force
2 个评论
Peter Man
2025-7-18
编辑:Peter Man
2025-7-18
This is surprising. "close all force" and "close all hidden" works for me (in 23b)
The training plot is a uifigure with HandleVisibility = "off". During training, it has a custom CloseRequestFcn to stop users from closing the window during training, but once training has finished, we set the CloseRequestFcn back to "closereq", which is the default closing callback for all uifigures. So after training, the uifigure has the following:
- HandleVisibility = "off"
- CloseRequestFcn = "closereq"
This combination means that either of the two calls should programmatically close the training plot:
- "close all hidden"
- "close all force" % This should work even if the CloseRequestFcn were something different to "closereq".
I recommend trying the following code, and posting the result:
f = uifigure();
f.HandleVisibility % I would like to know what this shows for you
f.CloseRequestFcn % I would like to know what this shows for you
close all hidden % Does this work for you?
close all force % Try this if the previous line doesn't work for you.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!