public class ArrayDataset extends RandomAccessDataset
ArrayDataset
is an implementation of RandomAccessDataset
that consist entirely of
large NDArray
s. There can be multiple data and label NDArray
s within the dataset.
Each sample will be retrieved by indexing each NDArray
along the first dimension.
The following is an example of how to use ArrayDataset:
ArrayDataset dataset = new ArrayDataset.Builder() .setData(data) .optLabels(label) .setSampling(20, false) .build();
Dataset
Modifier and Type | Class and Description |
---|---|
static class |
ArrayDataset.Builder
The Builder to construct an
ArrayDataset . |
RandomAccessDataset.BaseBuilder<T extends RandomAccessDataset.BaseBuilder<T>>
Dataset.Usage
Modifier and Type | Field and Description |
---|---|
protected NDArray[] |
data |
protected NDArray[] |
labels |
dataBatchifier, device, executor, labelBatchifier, limit, pipeline, prefetchNumber, sampler, targetPipeline
Constructor and Description |
---|
ArrayDataset(RandomAccessDataset.BaseBuilder<?> builder)
Creates a new instance of
ArrayDataset with the arguments in ArrayDataset.Builder . |
Modifier and Type | Method and Description |
---|---|
protected long |
availableSize()
Returns the number of records available to be read in this
Dataset . |
Record |
get(NDManager manager,
long index)
Gets the
Record for the given index from the dataset. |
void |
prepare(ai.djl.util.Progress progress)
Prepares the dataset for use with tracked progress.
|
getData, getData, randomSplit, size, subDataset, toArray
public ArrayDataset(RandomAccessDataset.BaseBuilder<?> builder)
ArrayDataset
with the arguments in ArrayDataset.Builder
.builder
- a builder with the required argumentsprotected long availableSize()
Dataset
.availableSize
in class RandomAccessDataset
Dataset
public Record get(NDManager manager, long index)
Record
for the given index from the dataset.get
in class RandomAccessDataset
manager
- the manager used to create the arraysindex
- the index of the requested data itemRecord
that contains the data and label of the requested data itempublic void prepare(ai.djl.util.Progress progress) throws java.io.IOException
progress
- the progress trackerjava.io.IOException
- for various exceptions depending on the dataset