1.torch.utils.data.
DataLoader
(dataset, batch_size=1, shuffle=False, sampler=None, batch_sampler=None, num_workers=0, collate_fn=<function default_collate>, pin_memory=False, drop_last=False, timeout=0, worker_init_fn=None)[SOURCE]
Data loader. Combines a dataset and a sampler, and provides single- or multi-process iterators over the dataset.组合数据集和采样器,提供数据集上的迭代器。
Parameters: |
|
---|
NOTE
By default, each worker will have its PyTorch seed set to base_seed + worker_id
, where base_seed
is a long generated by main process using its RNG. However, seeds for other libraies may be duplicated upon initializing workers (w.g., NumPy), causing each worker to return identical random numbers. (See My data loader workers return identical random numbers section in FAQ.) You may use torch.initial_seed()
to access the PyTorch seed for each worker in worker_init_fn
, and use it to set other seeds before data loading.
WARNING
If spawn
start method is used, worker_init_fn
cannot be an unpicklable object, e.g., a lambda function.