Package ai.djl.training.dataset
Interface Sampler
-
- All Known Implementing Classes:
BatchSampler
public interface Sampler
An interface for sampling data items from aRandomAccessDataset
.A
Sampler
implementation returns an iterator of batches for theRandomAccessDataset
. 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.SubSampler
s which sample not in batches but in individual data item indices.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Sampler.SubSampler
An interface that samples a single data item at a time.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getBatchSize()
Returns the batch size of theSampler
.java.util.Iterator<java.util.List<java.lang.Long>>
sample(RandomAccessDataset dataset)
Fetches an iterator that iterates through the givenRandomAccessDataset
in mini-batches of indices.
-
-
-
Method Detail
-
sample
java.util.Iterator<java.util.List<java.lang.Long>> sample(RandomAccessDataset dataset)
Fetches an iterator that iterates through the givenRandomAccessDataset
in mini-batches of indices.- Parameters:
dataset
- theRandomAccessDataset
to sample from- Returns:
- an iterator that iterates through the given
RandomAccessDataset
in 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
-
-