mindspore.dataset.dataloader.Dataset
- class mindspore.dataset.dataloader.Dataset[source]
Base class for implementing all datasets.
Map style datasets should inherit from it.
Map style datasets represent a mapping from keys to data samples. Subclasses must overwrite
__getitem__()
method, defining how to retrieve the samples according to the key. Subclasses could optionally overwrite__len__()
method, returning the total size of the samples. If not implemented, some built-in samplers andDataLoader
methods may not be available.Examples
>>> from mindspore.dataset.dataloader import Dataset >>> >>> class MapStyleDataset(Dataset): ... def __init__(self, data): ... self.data = data ... ... def __getitem__(self, index): ... return self.data[index] ... ... def __len__(self): ... return len(self.data)