Package ai.djl.training.dataset
Class DataIterable
- java.lang.Object
-
- ai.djl.training.dataset.DataIterable
-
- Direct Known Subclasses:
BulkDataIterable
public class DataIterable extends java.lang.Object implements java.lang.Iterable<Batch>, java.util.Iterator<Batch>
DataIterable is a data loader that combinesDataset,Batchifier,Pipeline, andSamplerto provide an iterable over the givenRandomAccessDataset.We don't recommended using DataIterable directly. Instead use
RandomAccessDatasetcombined withTrainerto iterate over theRandomAccessDataset}
-
-
Field Summary
Fields Modifier and Type Field Description protected BatchifierdataBatchifierprotected RandomAccessDatasetdatasetprotected Devicedeviceprotected BatchifierlabelBatchifierprotected NDManagermanagerprotected Pipelinepipelineprotected PipelinetargetPipeline
-
Constructor Summary
Constructors Constructor Description DataIterable(RandomAccessDataset 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 ofDataIterablewith the given parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Batchfetch(java.util.List<java.lang.Long> indices, int progress)booleanhasNext()java.util.Iterator<Batch>iterator()Batchnext()
-
-
-
Field Detail
-
dataset
protected RandomAccessDataset dataset
-
manager
protected NDManager manager
-
dataBatchifier
protected Batchifier dataBatchifier
-
labelBatchifier
protected Batchifier labelBatchifier
-
pipeline
protected Pipeline pipeline
-
targetPipeline
protected Pipeline targetPipeline
-
device
protected Device device
-
-
Constructor Detail
-
DataIterable
public DataIterable(RandomAccessDataset 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 ofDataIterablewith 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
-
iterator
public java.util.Iterator<Batch> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<Batch>
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<Batch>
-
fetch
protected Batch fetch(java.util.List<java.lang.Long> indices, int progress) throws java.io.IOException
- Throws:
java.io.IOException
-
-