2 Related question about Cross-Validation (In the scope of Neural Networks):
1) Let's say we train our neural network for 100 epochs and apply 5-fold cross validation. In that case, should I use the same folds over 100 epochs or at each epoch should epochs need to be re-created ? In other words which one of the following 2 pseudo code is correct ?
for i=1:EPOCH
folds = create_folds(training_data)
for j=1:length(folds)
for k in range(length(folds))
if j != k
model <- train(folds[j])
end
end
evaluate(model,folds[j])
reset-model-weights(model)
end
end
Or
folds = create_folds(training_data) # Look at the change in this line place
for i=1:EPOCH
for j=1:length(folds)
for k in range(length(folds))
if j != k
model <- train(folds[j])
end
end
evaluate(model,folds[j])
reset-model-weights(model)
end
end
2) My second question is if I have a single file for all train validation and test splits, should I keep test set constant ( I mean take the 10% of the file first and use that part always as a test set and then apply k-Fold cross validation for the remaning part for creating train/val sets) or should test set also be changed ?