Package org.nd4j.linalg.dataset
Class MultiDataSet
- java.lang.Object
-
- org.nd4j.linalg.dataset.MultiDataSet
-
- All Implemented Interfaces:
Serializable,MultiDataSet
public class MultiDataSet extends Object implements MultiDataSet
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MultiDataSet()Create a new (empty) MultiDataSet object (all fields are null)MultiDataSet(INDArray[] features, INDArray[] labels)MultiDataSet constructor with no mask arraysMultiDataSet(INDArray[] features, INDArray[] labels, INDArray[] featuresMaskArrays, INDArray[] labelsMaskArrays)MultiDataSet(INDArray[] features, INDArray[] labels, INDArray[] featuresMaskArrays, INDArray[] labelsMaskArrays, List<Serializable> exampleMetaData)MultiDataSet(INDArray features, INDArray labels)MultiDataSet constructor with single features/labels input, no mask arraysMultiDataSet(INDArray features, INDArray labels, INDArray featuresMask, INDArray labelsMask)MultiDataSet constructor with single features/labels input, single mask arrays
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<MultiDataSet>asList()SplitV the MultiDataSet into a list of individual examples.MultiDataSetcopy()Clone the datasetvoiddetach()This method migrates this DataSet into current Workspace (if any)booleanequals(Object o)List<Serializable>getExampleMetaData()Get the example metadata, or null if no metadata has been set<T extends Serializable>
List<T>getExampleMetaData(Class<T> metaDataType)Get the example metadata, or null if no metadata has been set
Note: this method results in an unchecked cast - care should be taken when using this!INDArray[]getFeatures()Get all of the input features, as an array of INDArraysINDArraygetFeatures(int index)Get a single feature/input arrayINDArraygetFeaturesMaskArray(int index)Get the specified feature mask array.INDArray[]getFeaturesMaskArrays()Get the feature mask arrays.INDArray[]getLabels()Get all of the labels, as an array of INDArraysINDArraygetLabels(int index)Get a single label/output arrayINDArraygetLabelsMaskArray(int index)Get the specified label mask array.INDArray[]getLabelsMaskArrays()Get the labels mask arrays.longgetMemoryFootprint()This method returns memory used by this DataSetinthashCode()booleanhasMaskArrays()Whether there are any mask arrays (features or labels) present for this MultiDataSetbooleanisEmpty()voidload(File from)Load the contents of this MultiDataSet from the specified filevoidload(InputStream from)Load the contents of this MultiDataSet from the specified stream.static MultiDataSetmerge(Collection<? extends MultiDataSet> toMerge)Merge a collection of MultiDataSet objects into a single MultiDataSet.voidmigrate()This method migrates this MultiDataSet into current Workspace (if any)intnumFeatureArrays()Number of arrays of features/input data in the MultiDataSetintnumLabelsArrays()Number of arrays of label/output data in the MultiDataSetvoidsave(File to)Save this MultiDataSet to the specified filevoidsave(OutputStream to)Save this MultiDataSet to the specified stream.voidsetExampleMetaData(List<? extends Serializable> exampleMetaData)Set the metadata for this MultiDataSet
By convention: the metadata can be any serializable object, one per example in the MultiDataSetvoidsetFeatures(int idx, INDArray features)Set a single features array (by index) for the MultiDataSetvoidsetFeatures(INDArray[] features)Set all of the features arrays for the MultiDataSetvoidsetFeaturesMaskArray(int idx, INDArray maskArray)Set a single feature mask array by indexvoidsetFeaturesMaskArrays(INDArray[] maskArrays)Set the feature mask arraysvoidsetLabels(int idx, INDArray labels)Set a single labels array (by index) for the MultiDataSetvoidsetLabels(INDArray[] labels)Set all of the labels arrays for the MultiDataSetvoidsetLabelsMaskArray(int idx, INDArray labelsMaskArray)Set a single labels mask array by indexvoidsetLabelsMaskArray(INDArray[] labelsMaskArrays)Set the labels mask arraysvoidshuffle()Shuffle the order of the examples in the MultiDataSet.StringtoString()
-
-
-
Constructor Detail
-
MultiDataSet
public MultiDataSet()
Create a new (empty) MultiDataSet object (all fields are null)
-
MultiDataSet
public MultiDataSet(INDArray features, INDArray labels)
MultiDataSet constructor with single features/labels input, no mask arrays
-
MultiDataSet
public MultiDataSet(INDArray features, INDArray labels, INDArray featuresMask, INDArray labelsMask)
MultiDataSet constructor with single features/labels input, single mask arrays
-
MultiDataSet
public MultiDataSet(INDArray[] features, INDArray[] labels)
MultiDataSet constructor with no mask arrays
-
MultiDataSet
public MultiDataSet(INDArray[] features, INDArray[] labels, INDArray[] featuresMaskArrays, INDArray[] labelsMaskArrays)
- Parameters:
features- The features (inputs) to the algorithm/neural networklabels- The labels (outputs) to the algorithm/neural networkfeaturesMaskArrays- The mask arrays for the features. May be null. Typically used with variable-length time series models, etclabelsMaskArrays- The mask arrays for the labels. May be null. Typically used with variable-length time series models, etc
-
MultiDataSet
public MultiDataSet(INDArray[] features, INDArray[] labels, INDArray[] featuresMaskArrays, INDArray[] labelsMaskArrays, List<Serializable> exampleMetaData)
- Parameters:
features- The features (inputs) to the algorithm/neural networklabels- The labels (outputs) to the algorithm/neural networkfeaturesMaskArrays- The mask arrays for the features. May be null. Typically used with variable-length time series models, etclabelsMaskArrays- The mask arrays for the labels. May be null. Typically used with variable-length time series models, etcexampleMetaData- Metadata for each example. May be null
-
-
Method Detail
-
getExampleMetaData
public List<Serializable> getExampleMetaData()
Description copied from interface:MultiDataSetGet the example metadata, or null if no metadata has been set- Specified by:
getExampleMetaDatain interfaceMultiDataSet- Returns:
- List of metadata instances
-
getExampleMetaData
public <T extends Serializable> List<T> getExampleMetaData(Class<T> metaDataType)
Description copied from interface:MultiDataSetGet the example metadata, or null if no metadata has been set
Note: this method results in an unchecked cast - care should be taken when using this!- Specified by:
getExampleMetaDatain interfaceMultiDataSet- Type Parameters:
T- Type of metadata- Parameters:
metaDataType- Class of the metadata (used for opType information)- Returns:
- List of metadata objects
-
setExampleMetaData
public void setExampleMetaData(List<? extends Serializable> exampleMetaData)
Description copied from interface:MultiDataSetSet the metadata for this MultiDataSet
By convention: the metadata can be any serializable object, one per example in the MultiDataSet- Specified by:
setExampleMetaDatain interfaceMultiDataSet- Parameters:
exampleMetaData- Example metadata to set
-
numFeatureArrays
public int numFeatureArrays()
Description copied from interface:MultiDataSetNumber of arrays of features/input data in the MultiDataSet- Specified by:
numFeatureArraysin interfaceMultiDataSet
-
numLabelsArrays
public int numLabelsArrays()
Description copied from interface:MultiDataSetNumber of arrays of label/output data in the MultiDataSet- Specified by:
numLabelsArraysin interfaceMultiDataSet
-
getFeatures
public INDArray[] getFeatures()
Description copied from interface:MultiDataSetGet all of the input features, as an array of INDArrays- Specified by:
getFeaturesin interfaceMultiDataSet
-
getFeatures
public INDArray getFeatures(int index)
Description copied from interface:MultiDataSetGet a single feature/input array- Specified by:
getFeaturesin interfaceMultiDataSet
-
setFeatures
public void setFeatures(INDArray[] features)
Description copied from interface:MultiDataSetSet all of the features arrays for the MultiDataSet- Specified by:
setFeaturesin interfaceMultiDataSet
-
setFeatures
public void setFeatures(int idx, INDArray features)Description copied from interface:MultiDataSetSet a single features array (by index) for the MultiDataSet- Specified by:
setFeaturesin interfaceMultiDataSet
-
getLabels
public INDArray[] getLabels()
Description copied from interface:MultiDataSetGet all of the labels, as an array of INDArrays- Specified by:
getLabelsin interfaceMultiDataSet
-
getLabels
public INDArray getLabels(int index)
Description copied from interface:MultiDataSetGet a single label/output array- Specified by:
getLabelsin interfaceMultiDataSet
-
setLabels
public void setLabels(INDArray[] labels)
Description copied from interface:MultiDataSetSet all of the labels arrays for the MultiDataSet- Specified by:
setLabelsin interfaceMultiDataSet
-
setLabels
public void setLabels(int idx, INDArray labels)Description copied from interface:MultiDataSetSet a single labels array (by index) for the MultiDataSet- Specified by:
setLabelsin interfaceMultiDataSet
-
hasMaskArrays
public boolean hasMaskArrays()
Description copied from interface:MultiDataSetWhether there are any mask arrays (features or labels) present for this MultiDataSet- Specified by:
hasMaskArraysin interfaceMultiDataSet
-
getFeaturesMaskArrays
public INDArray[] getFeaturesMaskArrays()
Description copied from interface:MultiDataSetGet the feature mask arrays. May return null if no feature mask arrays are present; otherwise, any entry in the array may be null if no mask array is present for that particular feature- Specified by:
getFeaturesMaskArraysin interfaceMultiDataSet
-
getFeaturesMaskArray
public INDArray getFeaturesMaskArray(int index)
Description copied from interface:MultiDataSetGet the specified feature mask array. Returns null if no feature mask is present for that particular feature/input- Specified by:
getFeaturesMaskArrayin interfaceMultiDataSet
-
setFeaturesMaskArrays
public void setFeaturesMaskArrays(INDArray[] maskArrays)
Description copied from interface:MultiDataSetSet the feature mask arrays- Specified by:
setFeaturesMaskArraysin interfaceMultiDataSet
-
setFeaturesMaskArray
public void setFeaturesMaskArray(int idx, INDArray maskArray)Description copied from interface:MultiDataSetSet a single feature mask array by index- Specified by:
setFeaturesMaskArrayin interfaceMultiDataSet
-
getLabelsMaskArrays
public INDArray[] getLabelsMaskArrays()
Description copied from interface:MultiDataSetGet the labels mask arrays. May return null if no labels mask arrays are present; otherwise, any entry in the array may be null if no mask array is present for that particular label- Specified by:
getLabelsMaskArraysin interfaceMultiDataSet
-
getLabelsMaskArray
public INDArray getLabelsMaskArray(int index)
Description copied from interface:MultiDataSetGet the specified label mask array. Returns null if no label mask is present for that particular feature/input- Specified by:
getLabelsMaskArrayin interfaceMultiDataSet
-
setLabelsMaskArray
public void setLabelsMaskArray(INDArray[] labelsMaskArrays)
Description copied from interface:MultiDataSetSet the labels mask arrays- Specified by:
setLabelsMaskArrayin interfaceMultiDataSet
-
setLabelsMaskArray
public void setLabelsMaskArray(int idx, INDArray labelsMaskArray)Description copied from interface:MultiDataSetSet a single labels mask array by index- Specified by:
setLabelsMaskArrayin interfaceMultiDataSet
-
save
public void save(OutputStream to) throws IOException
Description copied from interface:MultiDataSetSave this MultiDataSet to the specified stream. Stream will be closed after saving.- Specified by:
savein interfaceMultiDataSet- Throws:
IOException
-
save
public void save(File to) throws IOException
Description copied from interface:MultiDataSetSave this MultiDataSet to the specified file- Specified by:
savein interfaceMultiDataSet- Throws:
IOException
-
load
public void load(InputStream from) throws IOException
Description copied from interface:MultiDataSetLoad the contents of this MultiDataSet from the specified stream. Stream will be closed after loading.- Specified by:
loadin interfaceMultiDataSet- Throws:
IOException
-
load
public void load(File from) throws IOException
Description copied from interface:MultiDataSetLoad the contents of this MultiDataSet from the specified file- Specified by:
loadin interfaceMultiDataSet- Throws:
IOException
-
asList
public List<MultiDataSet> asList()
Description copied from interface:MultiDataSetSplitV the MultiDataSet into a list of individual examples.- Specified by:
asListin interfaceMultiDataSet- Returns:
- List of MultiDataSets, each with 1 example
-
copy
public MultiDataSet copy()
Clone the dataset- Specified by:
copyin interfaceMultiDataSet- Returns:
- a clone of the dataset
-
merge
public static MultiDataSet merge(Collection<? extends MultiDataSet> toMerge)
Merge a collection of MultiDataSet objects into a single MultiDataSet. Merging is done by concatenating along dimension 0 (example number in batch) Merging operation may introduce mask arrays (when necessary) for time series data that has different lengths; if mask arrays already exist, these will be merged also.- Parameters:
toMerge- Collection of MultiDataSet objects to merge- Returns:
- a single MultiDataSet object, containing the arrays of
-
getMemoryFootprint
public long getMemoryFootprint()
This method returns memory used by this DataSet- Specified by:
getMemoryFootprintin interfaceMultiDataSet- Returns:
-
migrate
public void migrate()
Description copied from interface:MultiDataSetThis method migrates this MultiDataSet into current Workspace (if any)- Specified by:
migratein interfaceMultiDataSet
-
detach
public void detach()
This method migrates this DataSet into current Workspace (if any)- Specified by:
detachin interfaceMultiDataSet
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceMultiDataSet- Returns:
- True if the MultiDataSet is empty (all features/labels arrays are empty)
-
shuffle
public void shuffle()
Description copied from interface:MultiDataSetShuffle the order of the examples in the MultiDataSet. Note that this generally won't make any difference in practice unless the MultiDataSet is later split.- Specified by:
shufflein interfaceMultiDataSet
-
-