| dataloader {torch} | R Documentation | 
Data loader. Combines a dataset and a sampler, and provides single- or multi-process iterators over the dataset.
Description
Data loader. Combines a dataset and a sampler, and provides single- or multi-process iterators over the dataset.
Usage
dataloader(
  dataset,
  batch_size = 1,
  shuffle = FALSE,
  sampler = NULL,
  batch_sampler = NULL,
  num_workers = 0,
  collate_fn = NULL,
  pin_memory = FALSE,
  drop_last = FALSE,
  timeout = -1,
  worker_init_fn = NULL,
  worker_globals = NULL,
  worker_packages = NULL
)
Arguments
| dataset | (Dataset): dataset from which to load the data. | 
| batch_size | (int, optional): how many samples per batch to load
(default:  | 
| shuffle | (bool, optional): set to  | 
| sampler | (Sampler, optional): defines the strategy to draw samples from
the dataset. If specified,  | 
| batch_sampler | (Sampler, optional): like sampler, but returns a batch of
indices at a time. Mutually exclusive with  | 
| num_workers | (int, optional): how many subprocesses to use for data
loading. 0 means that the data will be loaded in the main process.
(default:  | 
| collate_fn | (callable, optional): merges a list of samples to form a mini-batch. | 
| pin_memory | (bool, optional): If  | 
| drop_last | (bool, optional): set to  | 
| timeout | (numeric, optional): if positive, the timeout value for collecting a batch
from workers. -1 means no timeout. (default:  | 
| worker_init_fn | (callable, optional): If not  | 
| worker_globals | (list or character vector, optional) only used when
 | 
| worker_packages | (character vector, optional) Only used if  | 
Parallel data loading
When using num_workers > 0 data loading will happen in parallel for each
worker. Note that batches are taken in parallel and not observations.
The worker initialization process happens in the following order:
-  num_workersR sessions are initialized.
Then in each worker we perform the following actions:
- the - torchlibrary is loaded.
- a random seed is set both using - set.seed()and using- torch_manual_seed.
- packages passed to the - worker_packagesargument are loaded.
- objects passed trough the - worker_globalsparameters are copied into the global environment.
- the - worker_initfunction is ran with an- idargument.
- the dataset fetcher is copied to the worker.