Facial-Expression-Recognition.Pytorch icon indicating copy to clipboard operation
Facial-Expression-Recognition.Pytorch copied to clipboard

A problem about k_fold_number

Open orangesmellbear opened this issue 2 years ago • 3 comments

Dear Wu Jie: It's a great projects! I have a question about k_fold_number. In the code"parser.add_argument('--fold', default=1, type=int, help='k fold number')", if default=5, does the training represent 5 fold cross validation?Why in k_ fold_ In train, the value of "-- fold" is not fixed but (i+1)? Or does 10 fold cross validation mean that the value of "-- fold" is taken from 1 to 10 for training, and then the average value of 10 training results is taken?Can you explain it to me? Best wishes!

orangesmellbear avatar Oct 25 '22 12:10 orangesmellbear

The k_fold_number in the code represents the number of folds for performing k-fold cross-validation. The k in k-fold cross-validation refers to the number of folds.

In the code parser.add_argument('--fold', default=1, type=int, help='k fold number'), the default argument is set to 1, which means that by default, the program will perform 1-fold cross-validation. If the value of --fold is set to 5, for example, then the program will perform 5-fold cross-validation.

In k-fold cross-validation, the dataset is divided into k equal-sized parts, or folds. The model is trained on k-1 folds, and the remaining fold is used as the validation set. This process is repeated k times, with each fold being used once as the validation set. The final performance metric is then averaged over all k runs.

In the code, the i in k_fold_train(i) is used to keep track of which fold is being used for validation in each iteration. So if k_fold_number=10, then k_fold_train will be called 10 times, with i ranging from 0 to 9. On each iteration, the i-th fold will be used as the validation set, and the remaining k-1 folds will be used for training. The final result is the average of the performance metrics obtained from each iteration.

I hope this helps clear up your understanding of the k_fold_number in the code.

AKASHKRISHNABHUKYA avatar Feb 13 '23 16:02 AKASHKRISHNABHUKYA

@AKASHKRISHNABHUKYA Thanks for your help! It's a great explanation.

orangesmellbear avatar Feb 15 '23 02:02 orangesmellbear

thanks for your explanation! but what about the test set?

Ibtissam-SAADI avatar Feb 19 '23 19:02 Ibtissam-SAADI