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 = 0,
worker_init_fn = NULL
)
(Dataset): dataset from which to load the data.
(int, optional): how many samples per batch to load
(default: 1
).
(bool, optional): set to TRUE
to have the data reshuffled
at every epoch (default: FALSE
).
(Sampler, optional): defines the strategy to draw samples from
the dataset. If specified, shuffle
must be False.
(Sampler, optional): like sampler, but returns a batch of
indices at a time. Mutually exclusive with batch_size
,
shuffle
, sampler
, and drop_last
.
(int, optional): how many subprocesses to use for data
loading. 0 means that the data will be loaded in the main process.
(default: 0
)
(callable, optional): merges a list of samples to form a mini-batch.
(bool, optional): If TRUE
, the data loader will copy tensors
into CUDA pinned memory before returning them. If your data elements
are a custom type, or your collate_fn
returns a batch that is a custom type
see the example below.
(bool, optional): set to TRUE
to drop the last incomplete batch,
if the dataset size is not divisible by the batch size. If FALSE
and
the size of dataset is not divisible by the batch size, then the last batch
will be smaller. (default: FALSE
)
(numeric, optional): if positive, the timeout value for collecting a batch
from workers. Should always be non-negative. (default: 0
)
(callable, optional): If not NULL
, this will be called on each
worker subprocess with the worker id (an int in [0, num_workers - 1]
) as
input, after seeding and before data loading. (default: NULL
)