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.Object
The Builder to construct aRandomAccessDataset
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Batchifier
dataBatchifier
protected Device
device
protected Batchifier
labelBatchifier
protected long
limit
protected Pipeline
pipeline
protected int
prefetchNumber
protected Sampler
sampler
protected Pipeline
targetPipeline
-
Constructor Summary
Constructors Constructor Description BaseBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
addTargetTransform(Transform transform)
T
addTransform(Transform transform)
Sampler
getSampler()
Gets theSampler
for the dataset.T
optDataBatchifier(Batchifier dataBatchifier)
Sets theBatchifier
for the data.T
optDevice(Device device)
Sets theDevice
.T
optLabelBatchifier(Batchifier labelBatchifier)
Sets theBatchifier
for the labels.T
optLimit(long limit)
Sets this dataset's limit.T
optPipeline(Pipeline pipeline)
T
optPrefetchNumber(int prefetchNumber)
Sets the number of batches to prefetch at once.T
optTargetPipeline(Pipeline targetPipeline)
protected abstract T
self()
Returns this {code Builder} object.T
setSampling(int batchSize, boolean random)
Sets theSampler
with the given batch size.T
setSampling(int batchSize, boolean random, boolean dropLast)
Sets theSampler
with the given batch size.T
setSampling(Sampler sampler)
Sets theSampler
for 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 theSampler
with 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 theSampler
with 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 theSampler
for the dataset.- Parameters:
sampler
- theSampler
to be set- Returns:
- this
BaseBuilder
-
optDataBatchifier
public T optDataBatchifier(Batchifier dataBatchifier)
Sets theBatchifier
for the data.- Parameters:
dataBatchifier
- theBatchifier
to be set- Returns:
- this
BaseBuilder
-
optLabelBatchifier
public T optLabelBatchifier(Batchifier labelBatchifier)
Sets theBatchifier
for the labels.- Parameters:
labelBatchifier
- theBatchifier
to be set- Returns:
- this
BaseBuilder
-
addTransform
public T addTransform(Transform transform)
- Parameters:
transform
- theTransform
to be added- Returns:
- this builder
-
addTargetTransform
public T addTargetTransform(Transform transform)
- Parameters:
transform
- theTransform
to 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
-
-