MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / RepeatDataset

Class RepeatDataset

detrsmpl/data/datasets/dataset_wrappers.py:22–45  ·  view source on GitHub ↗

A wrapper of repeated dataset. The length of repeated dataset will be `times` larger than the original dataset. This is useful when the data loading time is long but the dataset is small. Using RepeatDataset can reduce the data loading time between epochs. Args: dataset

Source from the content-addressed store, hash-verified

20
21@DATASETS.register_module()
22class RepeatDataset(object):
23 """A wrapper of repeated dataset.
24
25 The length of repeated dataset will be `times` larger than the original
26 dataset. This is useful when the data loading time is long but the dataset
27 is small. Using RepeatDataset can reduce the data loading time between
28 epochs.
29
30 Args:
31 dataset (:obj:`Dataset`): The dataset to be repeated.
32 times (int): Repeat times.
33 """
34 def __init__(self, dataset: Dataset, times: int):
35 self.dataset = dataset
36 self.times = times
37 self.CLASSES = dataset.CLASSES
38
39 self._ori_len = len(self.dataset)
40
41 def __getitem__(self, idx: int):
42 return self.dataset[idx % self._ori_len]
43
44 def __len__(self):
45 return self.times * self._ori_len

Callers 1

build_datasetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected