What is proper format of ValidationData of TrainingOptions in TrainNetwork?

5 visualizzazioni (ultimi 30 giorni)
Currently, I am building a model that has one output layer through two input layers using the Deep Learning Toolbox.
My model is learning with datastore type input value through the TrainNetwork function.
('cds_Train' is train data and has same size and format with 'cds_Vali')
Traning with Datastore works well.
However, it is difficult to proceed with verification due to an issue regarding the input type of Validation Data in Training Options.
st=1; sf=1;
for ii=1:nv
for i=1:t
% XfTest{sf,1}=P(ii,:);
XfVali(sf,:)=P(ii,:);
XsVali(sf,:)=T(ii,i:t+i-1); YVali(sf,:)=T(ii,t+i);
sf=sf+1;
end
Vali_sdata(st,:)=T(ii,1:end);
Vali_fdata(st,:)=P(ii,1:end);
st=st+1;
end
ds_XfVali = arrayDatastore(XfVali',"IterationDimension",2);
ds_XsVali = arrayDatastore(XsVali);
ds_YVali = arrayDatastore(YVali);
cds_XVali = combine(ds_XfVali,ds_XsVali);
cds_Vali = combine(ds_XfVali,ds_XsVali,ds_YVali);
%.
%.
%.
%.
options = trainingOptions('adam', ...
'ExecutionEnvironment','cpu', ...
'MaxEpochs',100, ...
'GradientThreshold',1, ...
'Shuffle','every-epoch', ...
'MiniBatchSize',mb, ...
'VerboseFrequency',200, ...
'InitialLearnRate',0.005, ...
'L2Regularization',0.0000001, ...
'ValidationData',cds_Vali , ...
'ValidationFrequency',25, ...
'LearnRateSchedule','none', ...
'Verbose',0, ...
'Plots','training-progress');
[net, info]=trainNetwork(cds_Train, lgraph, options);
Case 1) 'ValidationData',cds_Vali, ...
Case 2) 'ValidationData',{cds_XVali,ds_YVali}, ...
Case 3) 'ValidationData',{ds_XsVali, ds_XfVali,ds_YVali}, ...
If DataStore is used for that value, I have tried various cases as above, but there are continuous errors.
Please let me know some idea or give your knowledge.

Risposte (1)

Avadhoot
Avadhoot il 28 Set 2023
Hi Daemo Lee,
I understand that you are facing an error in passing the validation data to your model. The Validation data input argument can be a datastore or a cell array. In your case, the datastore can be used as validation data. You have combined "XsVali", "XfVali", and "YVali" to create a combined datastore, which is read as a 1x3 cell array by the "read" function. This causes an error with the "ValidationData" input argument, as the data must be in the form of "{predictors, targets}".
You can change the lines of code which use the “combine” function in the following manner:
cds_XVali = combine(ds_XfVali,ds_XsVali,ReadOrder='sequential');
cds_Vali = combine(cdsXVali,ds_YVali);
  • The first line creates a sequential datastore that contains "ds_XfVali" and "ds_XsVali" in a concatenated form.
  • The second line creates a combined datastore that horizontally concatenates "cds_XVali" and "ds_YVali".
  • The result will be a 1x2 cell array in the proper format for validation data.
For more details on the proper format for Validation Data refer the following:
I hope it helps,
Regards,
Avadhoot.

Categorie

Scopri di più su Image Data Workflows in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by