if TRAIN_MODEL # SAVE TRUE AND OOF true = nparray oof = nparray VERBOSE = 2 # use 1 for interactive for fold in range5 # INDICES OF TRAIN AND VALID FOLDS valid_idx = 2fol
The code block is used to train the model and obtain the overall cross-validation score
If TRAIN_MODEL is True, then the model is trained and the true and oof (out-of-fold) predictions are saved
Else, if TRAIN_MODEL is False, we assume that the weights for the model have already been saved and we proceed to make predictions on the test set
For each of the 5 folds, we read the training and validation data from disk, build and train the model,
and then make predictions on the validation set. The predictions are then used to calculate the fold's CV score,
and the true and oof predictions are concatenated.
After training all folds, the overall CV score is calculated and printed to the console.
Finally, the memory is cleaned up and the session is cleared using K.clear_session()
原文地址: https://www.cveoy.top/t/topic/hcWj 著作权归作者所有。请勿转载和采集!