Splitting Datasets for Training
Splitting Datasets for Training and Validation
Deep Lake offers two approaches for splitting dataset for training and validation:
Fully random splitting by row number (index)
Pseudo-random splitting using Deep Lake's internal method that is optimized for fast streaming
Setting up the Environment
First, let's set up our environment and copy the Fashion MNIST dataset into your organization. This dataset is an image classification dataset that categorizes images by clothing type (trouser, shirt, etc.). Copying the dataset into your organization enables you to make edits.
If you run this tutorial again, you may load the dataset instead of copying it.
keyboard_arrow_down
Fully random splitting by row number (index)
Lets randomly split the dataset based on arbitrary row numbers:
Deep Lake refer to subsets of a dataset as views
:
Saving the Views (Optional)
In order to achieve reproducibility, you may save the views and use them in the future. Each saved view is assigned a id
for reference. Saved views are pointers to data, and they do not duplicate data in storage.
We can also load a view using:
When loading or saving a view, we can specify the flag optimize = True
, which rechunks the data for optimal streaming performance. Note that this is a computationally intensive and it will duplicate the data from the view at the storage location.
Pseudo-random Deep Lake splitting that is optimized for performance
If high performance is required without duplicating data, we recommend using Deep Lake's internal random_split
method, which splits the dataset pseudo-randomly in order to maintain fast streaming.
Training a Model Using Views
Views and datasets can be used interchangeably for training models. In this tutorial, we show how to create and iterate over dataloaders for the training and validation views, and a full tutorial for training a classification model on Fashion MNIST is available here.
Congrats! You successfully created dataloaders from Deep Lake views! 🎉
Last updated