pub trait Dataset {
type Item;
// Required methods
fn len(&self) -> usize;
fn get(&self, index: usize) -> Self::Item;
// Provided methods
fn cached(self, cache_dir: impl Into<PathBuf>) -> CachedDataset<Self>
where Self: Sized { ... }
fn iter(&self) -> Box<dyn Iterator<Item = Self::Item> + '_> { ... }
}
Expand description
Generic Dataset
trait, modeled after PyTorch’s utils.data.Dataset
.
It represents a collection of objects indexed in the range 0..len()
.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn cached(self, cache_dir: impl Into<PathBuf>) -> CachedDataset<Self>where
Self: Sized,
fn cached(self, cache_dir: impl Into<PathBuf>) -> CachedDataset<Self>where
Self: Sized,
Modifies the dataset to check a cache directory before reading.
If the cache entry is present, it’s used instead of the underlying get()
.
If the cache entry is absent, it will be created after calling get()
.