nemos.batching.DataLoader#
- class nemos.batching.DataLoader(*args, **kwargs)[source]#
Bases:
ProtocolProtocol for data loaders that stream batches.
The protocol itself allows batches as tuples of any length, but note that
GLM.stochastic_fitexpects(X, y)pairs. The variadic batch format is used on the solver-level viaAbstractSolver.stochastic_run.Requirements:
Must be re-iterable: calling
__iter__()must return a fresh iterator each time. This is required forn_passes > 1and because SVRG’s full gradient computation iterates through the data an additional time per pass.sample_batch()should be cheap and deterministic (e.g., the first batch that contains valid data).Batches should have consistent, non-zero sizes. Note that the solver’s
updatemethod will be recompiled for each unique batch size. This usually means just 2 compilations, as the last batch is almost always of a different size unless the number of samples is divisible by the batch size.
Attributes
Total number of samples in the dataset.
- __init__(*args, **kwargs)#
Methods
__init__(*args, **kwargs)Return a single batch for initialization purposes.