public class FixedBucketSampler
extends java.lang.Object
implements ai.djl.training.dataset.Sampler
FixedBucketSampler is a Sampler to be used with TextDataset, and PaddingStackBatchifier. It groups text data of same length, and samples them
together so that the amount of padding required is minimised. It also makes sure that the
sampling is random across epochs.| Constructor and Description |
|---|
FixedBucketSampler(int batchSize)
Constructs a new instance of
FixedBucketSampler with the given number of buckets, and
the given batch size. |
FixedBucketSampler(int batchSize,
int numBuckets)
Constructs a new instance of
FixedBucketSampler with the given number of buckets, and
the given batch size. |
FixedBucketSampler(int batchSize,
int numBuckets,
boolean dropLast,
boolean shuffle)
Constructs a new instance of
FixedBucketSampler with the given number of buckets, and
the given batch size. |
| Modifier and Type | Method and Description |
|---|---|
int |
getBatchSize() |
java.util.Iterator<java.util.List<java.lang.Long>> |
sample(ai.djl.training.dataset.RandomAccessDataset dataset) |
public FixedBucketSampler(int batchSize,
int numBuckets,
boolean dropLast,
boolean shuffle)
FixedBucketSampler with the given number of buckets, and
the given batch size.batchSize - the batch sizenumBuckets - the number of bucketsdropLast - whether to drop the last incomplete batchshuffle - whether to shuffle data randomyl while samplingpublic FixedBucketSampler(int batchSize,
int numBuckets)
FixedBucketSampler with the given number of buckets, and
the given batch size.batchSize - the batch sizenumBuckets - the number of bucketspublic FixedBucketSampler(int batchSize)
FixedBucketSampler with the given number of buckets, and
the given batch size.batchSize - the batch sizepublic java.util.Iterator<java.util.List<java.lang.Long>> sample(ai.djl.training.dataset.RandomAccessDataset dataset)
sample in interface ai.djl.training.dataset.Samplerpublic int getBatchSize()
getBatchSize in interface ai.djl.training.dataset.Sampler