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

Class RepeatDataset

diffplanner/datasets/dataset_wrappers.py:21–42  ·  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

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

Callers 1

build_datasetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected