Package ai.djl.training.dataset
Class BulkDataIterable
- java.lang.Object
-
- ai.djl.training.dataset.DataIterable
-
- ai.djl.training.dataset.BulkDataIterable
-
public class BulkDataIterable extends DataIterable
BulkDataIterable specializes DataIterable in usingArrayDataset.getByRange(NDManager, long, long)orArrayDataset.getByIndices(NDManager, long...)to createBatchinstances more efficiently.
-
-
Field Summary
-
Fields inherited from class ai.djl.training.dataset.DataIterable
dataBatchifier, dataset, device, labelBatchifier, manager, pipeline, targetPipeline
-
-
Constructor Summary
Constructors Constructor Description BulkDataIterable(ArrayDataset dataset, NDManager manager, Sampler sampler, Batchifier dataBatchifier, Batchifier labelBatchifier, Pipeline pipeline, Pipeline targetPipeline, java.util.concurrent.ExecutorService executor, int preFetchNumber, Device device)Creates a new instance ofBulkDataIterablewith the given parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Batchfetch(java.util.List<java.lang.Long> indices, int progress)static booleanisRange(java.util.List<java.lang.Long> indices)Checks whether the given indices actually represents a range.-
Methods inherited from class ai.djl.training.dataset.DataIterable
hasNext, iterator, next
-
-
-
-
Constructor Detail
-
BulkDataIterable
public BulkDataIterable(ArrayDataset dataset, NDManager manager, Sampler sampler, Batchifier dataBatchifier, Batchifier labelBatchifier, Pipeline pipeline, Pipeline targetPipeline, java.util.concurrent.ExecutorService executor, int preFetchNumber, Device device)
Creates a new instance ofBulkDataIterablewith the given parameters.- Parameters:
dataset- the dataset to iterate onmanager- the manager to create the arrayssampler- a sampler to sample data withdataBatchifier- a batchifier for datalabelBatchifier- a batchifier for labelspipeline- the pipeline of transforms to apply on the datatargetPipeline- the pipeline of transforms to apply on the labelsexecutor- anExecutorServicepreFetchNumber- the number of samples to prefetchdevice- theDevice
-
-
Method Detail
-
fetch
protected Batch fetch(java.util.List<java.lang.Long> indices, int progress) throws java.io.IOException
- Overrides:
fetchin classDataIterable- Throws:
java.io.IOException
-
isRange
public static boolean isRange(java.util.List<java.lang.Long> indices)
Checks whether the given indices actually represents a range.- Parameters:
indices- the indices to examine- Returns:
- whether the given indices are sorted in ascending order with no gap and has at least one element
-
-