Package ai.djl.training.dataset
Class RandomAccessDataset.BaseBuilder<T extends RandomAccessDataset.BaseBuilder<T>>
- java.lang.Object
-
- ai.djl.training.dataset.RandomAccessDataset.BaseBuilder<T>
-
- Direct Known Subclasses:
ArrayDataset.Builder
- Enclosing class:
- RandomAccessDataset
public abstract static class RandomAccessDataset.BaseBuilder<T extends RandomAccessDataset.BaseBuilder<T>> extends java.lang.ObjectThe Builder to construct aRandomAccessDataset.
-
-
Field Summary
Fields Modifier and Type Field Description protected BatchifierdataBatchifierprotected Devicedeviceprotected BatchifierlabelBatchifierprotected longlimitprotected Pipelinepipelineprotected intprefetchNumberprotected Samplersamplerprotected PipelinetargetPipeline
-
Constructor Summary
Constructors Constructor Description BaseBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TaddTargetTransform(Transform transform)TaddTransform(Transform transform)SamplergetSampler()Gets theSamplerfor the dataset.ToptDataBatchifier(Batchifier dataBatchifier)Sets theBatchifierfor the data.ToptDevice(Device device)Sets theDevice.ToptLabelBatchifier(Batchifier labelBatchifier)Sets theBatchifierfor the labels.ToptLimit(long limit)Sets this dataset's limit.ToptPipeline(Pipeline pipeline)ToptPrefetchNumber(int prefetchNumber)Sets the number of batches to prefetch at once.ToptTargetPipeline(Pipeline targetPipeline)protected abstract Tself()Returns this {code Builder} object.TsetSampling(int batchSize, boolean random)Sets theSamplerwith the given batch size.TsetSampling(int batchSize, boolean random, boolean dropLast)Sets theSamplerwith the given batch size.TsetSampling(Sampler sampler)Sets theSamplerfor the dataset.
-
-
-
Field Detail
-
sampler
protected Sampler sampler
-
dataBatchifier
protected Batchifier dataBatchifier
-
labelBatchifier
protected Batchifier labelBatchifier
-
pipeline
protected Pipeline pipeline
-
targetPipeline
protected Pipeline targetPipeline
-
prefetchNumber
protected int prefetchNumber
-
limit
protected long limit
-
device
protected Device device
-
-
Method Detail
-
setSampling
public T setSampling(int batchSize, boolean random)
Sets theSamplerwith the given batch size.- Parameters:
batchSize- the batch sizerandom- whether the sampling has to be random- Returns:
- this
BaseBuilder
-
setSampling
public T setSampling(int batchSize, boolean random, boolean dropLast)
Sets theSamplerwith the given batch size.- Parameters:
batchSize- the batch sizerandom- whether the sampling has to be randomdropLast- whether to drop the last incomplete batch- Returns:
- this
BaseBuilder
-
setSampling
public T setSampling(Sampler sampler)
Sets theSamplerfor the dataset.- Parameters:
sampler- theSamplerto be set- Returns:
- this
BaseBuilder
-
optDataBatchifier
public T optDataBatchifier(Batchifier dataBatchifier)
Sets theBatchifierfor the data.- Parameters:
dataBatchifier- theBatchifierto be set- Returns:
- this
BaseBuilder
-
optLabelBatchifier
public T optLabelBatchifier(Batchifier labelBatchifier)
Sets theBatchifierfor the labels.- Parameters:
labelBatchifier- theBatchifierto be set- Returns:
- this
BaseBuilder
-
addTransform
public T addTransform(Transform transform)
- Parameters:
transform- theTransformto be added- Returns:
- this builder
-
addTargetTransform
public T addTargetTransform(Transform transform)
- Parameters:
transform- theTransformto be added- Returns:
- this builder
-
optPrefetchNumber
public T optPrefetchNumber(int prefetchNumber)
Sets the number of batches to prefetch at once.- Parameters:
prefetchNumber- the number of batches to prefetch at once- Returns:
- this
BaseBuilder
-
optDevice
public T optDevice(Device device)
Sets theDevice.- Parameters:
device- the device- Returns:
- this
BaseBuilder
-
optLimit
public T optLimit(long limit)
Sets this dataset's limit.The limit is usually used for testing purposes to test only with a subset of the dataset.
- Parameters:
limit- the limit of this dataset's records- Returns:
- this
BaseBuilder
-
self
protected abstract T self()
Returns this {code Builder} object.- Returns:
- this
BaseBuilder
-
-