Plotting my own validation and loss graph while training a CNN

140 次查看(过去 30 天)
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.

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