MCPcopy Index your code
hub / github.com/hpcaitech/ColossalAI / DummyDataloader

Class DummyDataloader

examples/tutorial/large_batch_optimizer/train.py:13–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13class DummyDataloader:
14 def __init__(self, length, batch_size):
15 self.length = length
16 self.batch_size = batch_size
17
18 def generate(self):
19 data = torch.rand(self.batch_size, 3, 224, 224)
20 label = torch.randint(low=0, high=10, size=(self.batch_size,))
21 return data, label
22
23 def __iter__(self):
24 self.step = 0
25 return self
26
27 def __next__(self):
28 if self.step < self.length:
29 self.step += 1
30 return self.generate()
31 else:
32 raise StopIteration
33
34 def __len__(self):
35 return self.length
36
37
38def main():

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…