Package org.datavec.api.util.ndarray
Class RecordConverter
- java.lang.Object
-
- org.datavec.api.util.ndarray.RecordConverter
-
public class RecordConverter extends Object
- Author:
- Adam Gibson
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static INDArraytoArray(Collection<? extends Writable> record)Convert a record to an INDArray.static INDArraytoArray(DataType dataType, Collection<? extends Writable> record)Convert a record to an INDArray.static INDArraytoArray(DataType dataType, Collection<Writable> record, int size)Convert a record to an ndarraystatic INDArraytoMatrix(List<List<Writable>> records)Convert a set of records in to a matrix As pertoMatrix(DataType, List)but hardcoded to Float datatypestatic INDArraytoMatrix(DataType dataType, List<List<Writable>> records)Convert a set of records in to a matrixstatic INDArraytoMinibatchArray(@NonNull List<? extends Writable> l)Convert a record to an INDArray, for use in minibatch training.static List<Writable>toRecord(Schema schema, List<Object> source)Convert a collection into a `List`, i.e. static List<Writable>toRecord(INDArray array)Convert an ndarray to a recordstatic List<List<Writable>>toRecords(INDArray matrix)Convert a set of records in to a matrixstatic List<List<Writable>>toRecords(DataSet dataSet)Convert a DataSet to a matrixstatic INDArraytoTensor(List<List<List<Writable>>> records)Convert a set of records in to a matrix
-
-
-
Method Detail
-
toArray
public static INDArray toArray(DataType dataType, Collection<Writable> record, int size)
Convert a record to an ndarray- Parameters:
record- the record to convert- Returns:
- the array
-
toRecords
public static List<List<Writable>> toRecords(INDArray matrix)
Convert a set of records in to a matrix- Parameters:
matrix- the records ot convert- Returns:
- the matrix for the records
-
toTensor
public static INDArray toTensor(List<List<List<Writable>>> records)
Convert a set of records in to a matrix- Parameters:
records- the records ot convert- Returns:
- the matrix for the records
-
toMatrix
public static INDArray toMatrix(List<List<Writable>> records)
Convert a set of records in to a matrix As pertoMatrix(DataType, List)but hardcoded to Float datatype- Parameters:
records- the records ot convert- Returns:
- the matrix for the records
-
toMatrix
public static INDArray toMatrix(DataType dataType, List<List<Writable>> records)
Convert a set of records in to a matrix- Parameters:
records- the records ot convert- Returns:
- the matrix for the records
-
toArray
public static INDArray toArray(Collection<? extends Writable> record)
Convert a record to an INDArray. May contain a mix of Writables and row vector NDArrayWritables. As pertoArray(DataType, Collection)but hardcoded to Float datatype- Parameters:
record- the record to convert- Returns:
- the array
-
toArray
public static INDArray toArray(DataType dataType, Collection<? extends Writable> record)
Convert a record to an INDArray. May contain a mix of Writables and row vector NDArrayWritables.- Parameters:
record- the record to convert- Returns:
- the array
-
toMinibatchArray
public static INDArray toMinibatchArray(@NonNull @NonNull List<? extends Writable> l)
Convert a record to an INDArray, for use in minibatch training. That is, for an input record of length N, the output array has dimension 0 of size N (i.e., suitable for minibatch training in DL4J, for example).
The input list of writables must all be the same type (i.e., all NDArrayWritables or all non-array writables such as DoubleWritable etc).
Note that for NDArrayWritables, they must have leading dimension 1, and all other dimensions must match.
For example, row vectors are valid NDArrayWritables, as are 3d (usually time series) with shape [1, x, y], or 4d (usually images) with shape [1, x, y, z] where (x,y,z) are the same for all inputs- Parameters:
l- the records to convert- Returns:
- the array
- See Also:
for the "single example concatenation" version of this method
-
toRecord
public static List<Writable> toRecord(INDArray array)
Convert an ndarray to a record- Parameters:
array- the array to convert- Returns:
- the record
-
toRecord
public static List<Writable> toRecord(Schema schema, List<Object> source)
Convert a collection into a `List`, i.e. a record that can be used with other datavec methods. Uses a schema to decide what kind of writable to use. - Returns:
- a record
-
-