How to split data randomly and keep the same split for later run?

I first use split_by_rand_pct to split my data into training and validating. But how to save such split? I want to train my model for a while and stop. and then resume with exact the same training data without introducing any new data from previous validation set. How to do so with fastai?

Now I use databunch.save() and load_data to save/load the whole databunch. Is there any better way ?

You can save the split by using a seed when you do the split, ie seed=42.

3 Likes