View source: R/utils-data-dataloader.R
| dataloader | R Documentation |
Data loader. Combines a dataset and a sampler, and provides single- or multi-process iterators over the dataset.
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
)
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 |
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_workers R sessions are initialized.
Then in each worker we perform the following actions:
the torch library is loaded.
a random seed is set both using set.seed() and using torch_manual_seed.
packages passed to the worker_packages argument are loaded.
objects passed trough the worker_globals parameters are copied into the
global environment.
the worker_init function is ran with an id argument.
the dataset fetcher is copied to the worker.
dataset(), sampler()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.