MCPcopy Create free account
hub / github.com/OpenGVLab/UniFormerV2 / create_sampler

Function create_sampler

slowfast/datasets/utils.py:400–414  ·  view source on GitHub ↗

Create sampler for the given dataset. Args: dataset (torch.utils.data.Dataset): the given dataset. shuffle (bool): set to ``True`` to have the data reshuffled at every epoch. cfg (CfgNode): configs. Details can be found in slowfast/config/defa

(dataset, shuffle, cfg)

Source from the content-addressed store, hash-verified

398
399
400def create_sampler(dataset, shuffle, cfg):
401 """
402 Create sampler for the given dataset.
403 Args:
404 dataset (torch.utils.data.Dataset): the given dataset.
405 shuffle (bool): set to ``True`` to have the data reshuffled
406 at every epoch.
407 cfg (CfgNode): configs. Details can be found in
408 slowfast/config/defaults.py
409 Returns:
410 sampler (Sampler): the created sampler.
411 """
412 sampler = DistributedSampler(dataset) if cfg.NUM_GPUS >= 1 else None
413
414 return sampler
415
416
417def loader_worker_init_fn(dataset):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected