MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / __init__

Method __init__

lib/utils/data/dataloader.py:383–419  ·  view source on GitHub ↗
(self, dataset, batch_size=1, shuffle=False, sampler=None, batch_sampler=None,
                 num_workers=0, collate_fn=default_collate, pin_memory=False, drop_last=False,
                 timeout=0, worker_init_fn=None)

Source from the content-addressed store, hash-verified

381 """
382
383 def __init__(self, dataset, batch_size=1, shuffle=False, sampler=None, batch_sampler=None,
384 num_workers=0, collate_fn=default_collate, pin_memory=False, drop_last=False,
385 timeout=0, worker_init_fn=None):
386 self.dataset = dataset
387 self.batch_size = batch_size
388 self.num_workers = num_workers
389 self.collate_fn = collate_fn
390 self.pin_memory = pin_memory
391 self.drop_last = drop_last
392 self.timeout = timeout
393 self.worker_init_fn = worker_init_fn
394
395 if timeout < 0:
396 raise ValueError('timeout option should be non-negative')
397
398 if batch_sampler is not None:
399 if batch_size > 1 or shuffle or sampler is not None or drop_last:
400 raise ValueError('batch_sampler is mutually exclusive with '
401 'batch_size, shuffle, sampler, and drop_last')
402
403 if sampler is not None and shuffle:
404 raise ValueError('sampler is mutually exclusive with shuffle')
405
406 if self.num_workers < 0:
407 raise ValueError('num_workers cannot be negative; '
408 'use num_workers=0 to disable multiprocessing.')
409
410 if batch_sampler is None:
411 if sampler is None:
412 if shuffle:
413 sampler = RandomSampler(dataset)
414 else:
415 sampler = SequentialSampler(dataset)
416 batch_sampler = BatchSampler(sampler, batch_size, drop_last)
417
418 self.sampler = sampler
419 self.batch_sampler = batch_sampler
420
421 def __iter__(self):
422 return DataLoaderIter(self)

Callers

nothing calls this directly

Calls 3

RandomSamplerClass · 0.85
SequentialSamplerClass · 0.85
BatchSamplerClass · 0.85

Tested by

no test coverage detected