WuJie1010 / Facial-Expression-Recognition.Pytorch

A CNN based pytorch implementation on facial expression recognition (FER2013 and CK+), achieving 73.112% (state-of-the-art) in FER2013 and 94.64% in CK+ dataset
MIT License
1.77k stars 546 forks source link

A problem about k_fold_number #136

Open orangesmellbear opened 1 year ago

orangesmellbear commented 1 year ago

Dear Wu Jie: It's a great projects! I have a question about k_fold_number. In the code"parser.addargument('--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!

AKASHKRISHNABHUKYA commented 1 year ago

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.

orangesmellbear commented 1 year ago

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

Ibtissam-SAADI commented 1 year ago

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