Creates a new SamplerSource:
Samplers can be used with
dataloader() when creating batches from a torch
sampler( name = NULL, inherit = Sampler, ..., private = NULL, active = NULL, parent_env = parent.frame() )
(optional) name of the sampler
(optional) you can inherit from other samplers to re-use some methods.
Pass any number of fields or methods. You should at least define the
stepmethods. See the examples section.
(optional) a list of private methods for the sampler
(optional) a list of active methods for the sampler.
used to capture the right environment to define the class. The default is fine for most situations.
A sampler must implement the
initializetakes in a
data_source. In general this is a
.iterreturns a function that returns a dataset index everytime it's called.
.lengthreturns the maximum number of samples that can be retrieved from that sampler.