Azzera filtri
Azzera filtri

Plot validation curve of Neural Network

9 visualizzazioni (ultimi 30 giorni)
Jacky Liu
Jacky Liu il 13 Nov 2017
Commentato: sinan salim il 5 Apr 2020
I just download and run the sample code "Deep Learning Example: Training from scratch using CIFAR-10 Dataset" Demo_TrainingFromScratch.mlx
I could get the accuracy plot by adding
into trainingOptions.
However, this only plot training accuracy.
How can I modify this example to also plot validation accuracy like this page ?
When I execute
[net, info] = trainNetwork(imds_Train.Files,imds_Train.Labels, layers, opts);
It print out error message:
Error using trainNetwork (line 140)
Invalid training data. X must be a 4-D array of images, an ImageDatastore, or a table.

Risposte (2)

Bhartendu il 8 Apr 2018
1. For Validation accuracy and it's plot:
  • Perform CV partition as follows:
X = imds_Train.Files
Y = imds_Train.Labels
num_images = size(X,4);
% Precentage of split
Percent = 30
idx = randperm(num_images,Percent/100*num_images);
X_val = X(:,:,:,idx);
X(:,:,:,idx) = [];
Y_val = Y(idx);
Y(idx) = [];
disp(['Training samples: ', length(Y), ' Validation samples: ', length(Y_val)])
  • Modify for ValidationData in the options like:
options = trainingOptions('sgdm',...
'MaxEpochs', 50 ,...
'ValidationData',{X_val,Y_val} ,...
'MiniBatchSize', 64 ,...
'InitialLearnRate', 1e-4 ,...
'ValidationPatience', 10,...
'Verbose', 1 ,...
2. For Error using trainNetwork: Check my answer here

Maria Duarte Rosa
Maria Duarte Rosa il 15 Dic 2017
Hi Jacky,
When you work with imageDatastore you do not need to pass the files and labels separately into trainNetwork and also into the 'ValidationData' argument of trainingOptions. You can simply do:
[net, info] = trainNetwork(imds_Train, layers, opts);
And (in 'trainingOptions'):
I hope this helps.
Please see here for more details: trainNetwork, trainingOptions
  1 Commento
sinan salim
sinan salim il 5 Apr 2020
how can find the imds_Validation,,if i will put the imds-Train instedt of the validation data ,will give low validation accuraccy ,else without mention the validation ,,its will plot the curve but will not show the validation of accuracy just will refer to NaN
so what will be the solution ?

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by