annbatch.samplers.SequentialSampler#
- class annbatch.samplers.SequentialSampler(chunk_size, preload_nchunks, batch_size, *, drop_last=False, mask=None)#
Ordered chunk-based sampler for batched data access.
Chunks are emitted in sequential order and every observation in the range is visited exactly once. This sampler does not support multiple data-loading workers. This sampler is usually used for evaluation or inference.
See
RandomSamplerfor a shuffled alternative.- Parameters:
- batch_size
int Number of observations per batch.
- chunk_size
int Size of each chunk i.e. the range of each chunk yielded.
- mask
slice|None(default:None) A slice defining the observation range to sample from (start:stop).
- preload_nchunks
int Number of chunks to load per iteration.
- drop_last
bool(default:False) Whether to drop the last incomplete batch.
- batch_size
Attributes table#
The batch size for data loading. |
|
The observation range this sampler operates on. |
|
The random number generator used by this sampler. |
|
Whether data is shuffled. |
Methods table#
Attributes#
- SequentialSampler.batch_size#
- SequentialSampler.mask#
The observation range this sampler operates on.
- SequentialSampler.rng#
The random number generator used by this sampler.
- SequentialSampler.shuffle#
Methods#
- SequentialSampler.n_iters(n_obs)#
Return the number of batches.
- SequentialSampler.sample(n_obs)#
Sample load requests given the total number of observations.
Base implemention simply calls
validate()and then yields via_sample().- Parameters:
- n_obs
int The total number of observations available.
- n_obs
- Yields:
LoadRequest – Load requests for batching data.
- Return type:
- SequentialSampler.validate(n_obs)#
Validate the sampler configuration against the loader’s n_obs.
- Parameters:
- n_obs
int The total number of observations in the loader.
- n_obs
- Raises:
ValueError – If the sampler configuration is invalid for the given n_obs.
- Return type: