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 Object
The Builder to construct a RandomAccessDataset.
  • Field Details

    • 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
  • Constructor Details

    • BaseBuilder

      public BaseBuilder()
  • Method Details

    • getSampler

      public Sampler getSampler()
      Gets the Sampler for the dataset.
      Returns:
      the Sampler
    • setSampling

      public T setSampling(int batchSize, boolean random)
      Sets the Sampler with the given batch size.
      Parameters:
      batchSize - the batch size
      random - whether the sampling has to be random
      Returns:
      this BaseBuilder
    • setSampling

      public T setSampling(int batchSize, boolean random, boolean dropLast)
      Sets the Sampler with the given batch size.
      Parameters:
      batchSize - the batch size
      random - whether the sampling has to be random
      dropLast - whether to drop the last incomplete batch
      Returns:
      this BaseBuilder
    • setSampling

      public T setSampling(Sampler sampler)
      Sets the Sampler for the dataset.
      Parameters:
      sampler - the Sampler to be set
      Returns:
      this BaseBuilder
    • optDataBatchifier

      public T optDataBatchifier(Batchifier dataBatchifier)
      Sets the Batchifier for the data.
      Parameters:
      dataBatchifier - the Batchifier to be set
      Returns:
      this BaseBuilder
    • optLabelBatchifier

      public T optLabelBatchifier(Batchifier labelBatchifier)
      Sets the Batchifier for the labels.
      Parameters:
      labelBatchifier - the Batchifier to be set
      Returns:
      this BaseBuilder
    • optPipeline

      public T optPipeline(Pipeline pipeline)
      Sets the Pipeline of Transform to be applied on the data.
      Parameters:
      pipeline - the Pipeline of Transform to be applied on the data
      Returns:
      this BaseBuilder
    • addTransform

      public T addTransform(Transform transform)
      Adds the Transform to the Pipeline to be applied on the data.
      Parameters:
      transform - the Transform to be added
      Returns:
      this builder
    • optTargetPipeline

      public T optTargetPipeline(Pipeline targetPipeline)
      Sets the Pipeline of Transform to be applied on the labels.
      Parameters:
      targetPipeline - the Pipeline of Transform to be applied on the labels
      Returns:
      this BaseBuilder
    • addTargetTransform

      public T addTargetTransform(Transform transform)
      Adds the Transform to the target Pipeline to be applied on the labels.
      Parameters:
      transform - the Transform 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 the Device.
      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