Leave-out-one cross validation during neural network training
9 Commenti
Hi Isabelle,
No problem. To extract the training data, you can exclude the index used for validation from the total indices available. You can achieve this by creating a vector of indices excluding the current validation index by modifying your code snippet to achieve this
% Train the network
for i = 1:length(XTrain) % Iterate over all data points
validationdataX = XTrain(i);
validationdataY = YTrain(i);% Exclude the current index (i) for training
trainingIndices = setdiff(1:length(XTrain), i);
trainingdataX = XTrain(trainingIndices);
trainingdataY = YTrain(trainingIndices); options = trainingOptions("adam", ...
'MaxEpochs', 60, ...
'MiniBatchSize', 1, ...
'InputDataFormat', "CTB", ...
'Plots', "training-progress", ...
'Metrics', "rmse", ...
'Verbose', 0, ...
'ValidationData', {validationdataX, validationdataY} ...
);net = trainnet(trainingdataX, trainingdataY, net, "mse", options); end
So, in this modified code snippet, ‘setdiff` function is used to exclude the current index (i) from the list of indices, `trainingdataX` and `trainingdataY` are populated with the remaining 9 trials for training and finally the loop iterates over all data points, excluding one at a time for validation. So, by implementing this approach, you should be able to effectively train your neural network model using the specified data separation for training and validation.
Let me know if you need further clarification or assistance with this problem-solving task.
Risposte (0)
Categorie
Scopri di più su Built-In Training in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!