Package ai.djl.basicdataset.utils
Class FixedBucketSampler
java.lang.Object
ai.djl.basicdataset.utils.FixedBucketSampler
- All Implemented Interfaces:
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface ai.djl.training.dataset.Sampler
ai.djl.training.dataset.Sampler.SubSampler -
Constructor Summary
ConstructorsConstructorDescriptionFixedBucketSampler(int batchSize) Constructs a new instance ofFixedBucketSamplerwith the given number of buckets, and the given batch size.FixedBucketSampler(int batchSize, int numBuckets) Constructs a new instance ofFixedBucketSamplerwith the given number of buckets, and the given batch size.FixedBucketSampler(int batchSize, int numBuckets, boolean shuffle) Constructs a new instance ofFixedBucketSamplerwith the given number of buckets, and the given batch size. -
Method Summary
Modifier and TypeMethodDescriptionintsample(ai.djl.training.dataset.RandomAccessDataset dataset)
-
Constructor Details
-
FixedBucketSampler
public FixedBucketSampler(int batchSize, int numBuckets, boolean shuffle) Constructs a new instance ofFixedBucketSamplerwith the given number of buckets, and the given batch size.- Parameters:
batchSize- the batch sizenumBuckets- the number of bucketsshuffle- whether to shuffle data randomly while sampling
-
FixedBucketSampler
public FixedBucketSampler(int batchSize, int numBuckets) Constructs a new instance ofFixedBucketSamplerwith the given number of buckets, and the given batch size.- Parameters:
batchSize- the batch sizenumBuckets- the number of buckets
-
FixedBucketSampler
public FixedBucketSampler(int batchSize) Constructs a new instance ofFixedBucketSamplerwith the given number of buckets, and the given batch size.- Parameters:
batchSize- the batch size
-
-
Method Details
-
sample
- Specified by:
samplein interfaceai.djl.training.dataset.Sampler
-
getBatchSize
public int getBatchSize()- Specified by:
getBatchSizein interfaceai.djl.training.dataset.Sampler
-