Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any support of k-fold cross validation? #65

Open
emadeldeen24 opened this issue Jan 31, 2020 · 4 comments
Open

any support of k-fold cross validation? #65

emadeldeen24 opened this issue Jan 31, 2020 · 4 comments

Comments

@emadeldeen24
Copy link

No description provided.

@LumosWC
Copy link

LumosWC commented Feb 23, 2020

yeah please. Or any suggestions on how to modify the code if I want to use k-fold cross validation please?

@SunQpark
Copy link
Collaborator

Sorry for late response. K-fold CV can be done by modifying BaseDataLoader.

Current implementation of _split_sampler use first n samples of dataset as validation set. Modify this function to take additional argument, fold_idx and to use specified part of dataset.
To be more specific, this part should be changed to following.

valid_idx = idx_full[len_valid*fold_idx, len_valid*(fold_idx+1)]
train_idx = np.delete(idx_full, np.arange(0, len_valid))

Then, add the fold_idx to BaseDataLoader.__init__ and YourDataLoader.__init__, specify it in the config file, under data_loader.args.

@hsinlichu
Copy link

@SunQpark I think you mean

valid_idx = idx_full[len_valid * fold_idx : len_valid * (fold_idx + 1)]
train_idx = np.delete(idx_full, np.arange(len_valid * fold_idx, len_valid * (fold_idx + 1)))

@deeperlearner
Copy link

I have implemented cross validation to my Pytorch-Template
See #88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants