Package ai.djl.training.dataset
Interface Sampler
- All Known Implementing Classes:
BatchSampler
public interface Sampler
An interface for sampling data items from a
RandomAccessDataset.
A Sampler implementation returns an iterator of batches for the RandomAccessDataset. Instead of returning the actual items, it returns the item indices.
Different samplers can have different ways of sampling such as sampling with or without
replacement.
Many of the samplers may also make use of Sampler.SubSamplers which sample not in batches but
in individual data item indices.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn interface that samples a single data item at a time. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the batch size of theSampler.sample(RandomAccessDataset dataset) Fetches an iterator that iterates through the givenRandomAccessDatasetin mini-batches of indices.
-
Method Details
-
sample
Fetches an iterator that iterates through the givenRandomAccessDatasetin mini-batches of indices.- Parameters:
dataset- theRandomAccessDatasetto sample from- Returns:
- an iterator that iterates through the given
RandomAccessDatasetin mini-batches of indices
-
getBatchSize
int getBatchSize()Returns the batch size of theSampler.- Returns:
- the batch size of the
Sampler, -1 if batch size is not fixed
-