Plotting my own validation and loss graph while training a CNN

조회 수: 50 (최근 30일)
Thomas Groeneveld
Thomas Groeneveld 2020년 2월 26일
답변: KSSV 2023년 10월 14일
Within the Deep learning Toolbox it's possible to enable the training plots within the options. It uses the following code:
Options = trainingOptions('Plots', 'training-progress');
This opens an overview of the accuracy and loss while training, like this:
I think these two plots/graphs are amazing for the analysis of the CNN. Now, I've ran into an issue regarding enabling the option mentioned above.
This plot reporter causes conflicts when trying to use it in a standalone application using MATLAB Compiler. This conflict can be resolved by simply removing the 'Plots', 'training-progress' from the options. When removing this, you lose the two plots/graphs aswell.
I've tried to see where the measurements are stored during the plotting so I could extract the data and make my own plots/graphs. This was without sucess.
Now my question is: Is it possible to make my own accuracy and loss graphs by somehow extracting the data the program would have used to create the plots with the 'Plots' option enabled?
Any insight would help.
Greetings,
Thomas
  댓글 수: 1
Adam
Adam 2020년 2월 26일
I wanted to do something similar with a Self Organising Map (selforgmap), which uses a neural network (albeit a shallow simple one), but was told by Mathworks tech support that there is no option to add my own callback to be run each epoch/iteration/whenever I choose, which is what I would have needed to do. The SOM similarly can update its own specific plots while training (e.g. plotsomhits), but not custom plots.
I don't know what the solution would be for a Deep Learning example. For the SOM, I ended up writing my own SOM class so I could control everything myself, but that is a lot less feasible for deep learning networks.

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

답변 (2개)

Muhammad Faisal
Muhammad Faisal 2020년 7월 21일
When you call trainNetwork function, you need to return two outputs something like below
[net netinfo] = trainNetwork(......
This netinfo has Training and Validation Accuracies and Losses.
Now you can plot by using the below code
figure
plot(netinfo.TrainingLoss,'b-')
hold on
x = 1 : length(netinfo.ValidationLoss);
y = netinfo.ValidationLoss;
idx = ~any(isnan(y),1);
plot(x(idx),y(idx),'--k','Marker','.','MarkerSize' ,12);
You can add legends, xlabel, ylabel, etc. as per your requirement.
  댓글 수: 1
Maha Mosalam
Maha Mosalam 2021년 3월 12일
this is versus no of iterations ?....if I want to plot them versus epochs ??.. thanks un advance

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


KSSV
KSSV 2023년 10월 14일
[net,info] = traiNetwork() ; % you need to train the network
rmse = info.TrainingRMSE ; % get the RMSE curve from info
epochs = linspace(1,num_epochs,length(rmse)) ; % num_epochs are totak epochs you have specified
plot(epochs,rmse)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by