Class SamplingDataSetIterator
- java.lang.Object
-
- org.nd4j.linalg.dataset.api.iterator.SamplingDataSetIterator
-
- All Implemented Interfaces:
Serializable
,Iterator<DataSet>
,DataSetIterator
public class SamplingDataSetIterator extends Object implements DataSetIterator
A wrapper for a dataset to sample from. This will randomly sample from the given dataset.- Author:
- Adam Gibson
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SamplingDataSetIterator(DataSet sampleFrom, int batchSize, int totalNumberSamples)
SamplingDataSetIterator(DataSet sampleFrom, int batchSize, int totalNumberSamples, boolean replace)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
asyncSupported()
Does this DataSetIterator support asynchronous prefetching of multiple DataSet objects? Most DataSetIterators do, but in some cases it may not make sense to wrap this iterator in an iterator that does asynchronous prefetching.int
batch()
Batch sizeList<String>
getLabels()
Get dataset iterator class labels, if any.DataSetPreProcessor
getPreProcessor()
Returns preprocessors, if definedboolean
hasNext()
int
inputColumns()
Input columns for the datasetDataSet
next()
DataSet
next(int num)
Like the standard next method but allows a customizable number of examples returnedvoid
remove()
void
reset()
Resets the iterator back to the beginningboolean
resetSupported()
Is resetting supported by this DataSetIterator? Many DataSetIterators do support resetting, but some don'tvoid
setPreProcessor(DataSetPreProcessor preProcessor)
Set a pre processorint
totalOutcomes()
The number of labels for the dataset-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
SamplingDataSetIterator
public SamplingDataSetIterator(DataSet sampleFrom, int batchSize, int totalNumberSamples, boolean replace)
- Parameters:
sampleFrom
- the dataset to sample frombatchSize
- the batch size to sampletotalNumberSamples
- the sample size
-
SamplingDataSetIterator
public SamplingDataSetIterator(DataSet sampleFrom, int batchSize, int totalNumberSamples)
- Parameters:
sampleFrom
- the dataset to sample frombatchSize
- the batch size to sampletotalNumberSamples
- the sample size
-
-
Method Detail
-
inputColumns
public int inputColumns()
Description copied from interface:DataSetIterator
Input columns for the dataset- Specified by:
inputColumns
in interfaceDataSetIterator
- Returns:
-
totalOutcomes
public int totalOutcomes()
Description copied from interface:DataSetIterator
The number of labels for the dataset- Specified by:
totalOutcomes
in interfaceDataSetIterator
- Returns:
-
resetSupported
public boolean resetSupported()
Description copied from interface:DataSetIterator
Is resetting supported by this DataSetIterator? Many DataSetIterators do support resetting, but some don't- Specified by:
resetSupported
in interfaceDataSetIterator
- Returns:
- true if reset method is supported; false otherwise
-
asyncSupported
public boolean asyncSupported()
Description copied from interface:DataSetIterator
Does this DataSetIterator support asynchronous prefetching of multiple DataSet objects? Most DataSetIterators do, but in some cases it may not make sense to wrap this iterator in an iterator that does asynchronous prefetching. For example, it would not make sense to use asynchronous prefetching for the following types of iterators: (a) Iterators that store their full contents in memory already (b) Iterators that re-use features/labels arrays (as future next() calls will overwrite past contents) (c) Iterators that already implement some level of asynchronous prefetching (d) Iterators that may return different data depending on when the next() method is called- Specified by:
asyncSupported
in interfaceDataSetIterator
- Returns:
- true if asynchronous prefetching from this iterator is OK; false if asynchronous prefetching should not be used with this iterator
-
reset
public void reset()
Description copied from interface:DataSetIterator
Resets the iterator back to the beginning- Specified by:
reset
in interfaceDataSetIterator
-
batch
public int batch()
Description copied from interface:DataSetIterator
Batch size- Specified by:
batch
in interfaceDataSetIterator
- Returns:
-
setPreProcessor
public void setPreProcessor(DataSetPreProcessor preProcessor)
Set a pre processor- Specified by:
setPreProcessor
in interfaceDataSetIterator
- Parameters:
preProcessor
- a pre processor to set
-
getPreProcessor
public DataSetPreProcessor getPreProcessor()
Description copied from interface:DataSetIterator
Returns preprocessors, if defined- Specified by:
getPreProcessor
in interfaceDataSetIterator
- Returns:
-
getLabels
public List<String> getLabels()
Description copied from interface:DataSetIterator
Get dataset iterator class labels, if any. Note that implementations are not required to implement this, and can simply return null- Specified by:
getLabels
in interfaceDataSetIterator
-
next
public DataSet next(int num)
Description copied from interface:DataSetIterator
Like the standard next method but allows a customizable number of examples returned- Specified by:
next
in interfaceDataSetIterator
- Parameters:
num
- the number of examples- Returns:
- the next data applyTransformToDestination
-
-