MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / RepeatedData

Class RepeatedData

tensorpack/dataflow/common.py:361–392  ·  view source on GitHub ↗

Take data points from another DataFlow and produce them until it's exhausted for certain amount of times. i.e.: dp1, dp2, .... dpn, dp1, dp2, ....dpn

Source from the content-addressed store, hash-verified

359
360
361class RepeatedData(ProxyDataFlow):
362 """ Take data points from another DataFlow and produce them until
363 it's exhausted for certain amount of times. i.e.:
364 dp1, dp2, .... dpn, dp1, dp2, ....dpn
365 """
366
367 def __init__(self, ds, num):
368 """
369 Args:
370 ds (DataFlow): input DataFlow
371 num (int): number of times to repeat ds.
372 Set to -1 to repeat ``ds`` infinite times.
373 """
374 self.num = num
375 super(RepeatedData, self).__init__(ds)
376
377 def __len__(self):
378 """
379 Raises:
380 :class:`ValueError` when num == -1.
381 """
382 if self.num == -1:
383 raise NotImplementedError("__len__() is unavailable for infinite dataflow")
384 return len(self.ds) * self.num
385
386 def __iter__(self):
387 if self.num == -1:
388 while True:
389 yield from self.ds
390 else:
391 for _ in range(self.num):
392 yield from self.ds
393
394
395class RepeatedDataPoint(ProxyDataFlow):

Callers 7

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
reset_stateMethod · 0.85
__init__Method · 0.85
view_dataFunction · 0.85
get_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected