aistore.pytorch.dynamic_sampler
aistore.pytorch.dynamic_sampler
Dynamic Batch Sampler for Dynamic Batch Sizing
In scenarios where memory is a constraint, the DynamicBatchSampler can be used to generate mini-batches that fit within a memory constraint so that there is a guarantee that each batch fits within memory while attempting to fit the maximum number of samples in each batch.
Copyright (c) 2024-2025, NVIDIA CORPORATION. All rights reserved.
Module Contents
Classes
Data
API
Bases: Sampler
Dynamically adds samples to mini-batch up to a maximum batch size.
NOTE: Using this sampler with AISBaseMapDatasets that use ObjectGroups in their ais_source_lists will be slower than using it with Buckets as ObjectGroups will perform one extra API call per object to get size metadata.
Parameters:
Base AIS map-style dataset to sample from to create dynamic mini-batches.
Maximum size of mini-batch in bytes.
If True, then will drop last batch if the batch is not at least 80% of
max_batch_size. Defaults to False.
If True, then any sample that is larger than the max_batch_size
will be processed in its own min-batch by itself instead of being dropped. Defaults to False.
Saturation of a batch needed to not be dropped with drop_last=True.
Default is 0.8.
Randomizes order of samples before calculating mini-batches. Default is False.
Returns an iterator containing mini-batches (lists of indices).
Returns the total number of samples.
Get next index from indices if shuffling or otherwise return incremented count.
Returns: int
Next index to sample from