Package org.nd4j.linalg.factory
Class BaseNDArrayFactory
- java.lang.Object
-
- org.nd4j.linalg.factory.BaseNDArrayFactory
-
- All Implemented Interfaces:
NDArrayFactory
public abstract class BaseNDArrayFactory extends Object implements NDArrayFactory
-
-
Constructor Summary
Constructors Modifier Constructor Description BaseNDArrayFactory()
protected
BaseNDArrayFactory(DataType dtype, char order)
protected
BaseNDArrayFactory(DataType dtype, Character order)
Initialize with the given data opType and ordering The ndarray factory will use this for
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description INDArray
appendBias(INDArray... vectors)
Merge the vectors and append a bias.INDArray
arange(double begin, double end, double step)
Array of evenly spaced values.INDArray
bilinearProducts(INDArray curr, INDArray in)
Returns a column vector where each entry is the nth bilinear product of the nth slices of the two tensors.Blas
blas()
Return extra blas operationsINDArray
concat(int dimension, INDArray... toConcat)
concatenate ndarrays along a dimensionvoid
copy(INDArray a, INDArray b)
Copy a to bINDArray
create(double[] data)
Creates a row vector with the dataINDArray
create(double[] data, char order)
INDArray
create(double[] data, int[] shape)
Create an ndrray with the specified shapeINDArray
create(double[] data, int[] shape, int[] stride, char order, long offset)
abstract INDArray
create(double[] data, int[] shape, int[] stride, long offset)
Creates an ndarray with the specified shapeINDArray
create(double[] data, long[] shape)
INDArray
create(double[] data, long rows, long columns, int[] stride, long offset)
Creates an ndarray with the specified shapeINDArray
create(float[] data)
Creates a row vector with the dataINDArray
create(float[] data, char order)
INDArray
create(float[] data, int[] shape)
Create an ndrray with the specified shapeINDArray
create(float[] data, int[] shape, char ordering)
INDArray
create(float[] data, int[] shape, int[] stride, char order, long offset)
abstract INDArray
create(float[] data, int[] shape, int[] stride, long offset)
Creates an ndarray with the specified shapeINDArray
create(float[] data, int[] shape, long offset)
INDArray
create(float[] data, long[] shape)
abstract INDArray
create(float[] data, long[] shape, long[] stride, char order, DataType dataType, MemoryWorkspace workspace)
INDArray
create(float[] data, long rows, long columns, int[] stride, long offset)
Creates an ndarray with the specified shapeINDArray
create(int[] shape)
Creates an ndarray with the specified shapeINDArray
create(int[] shape, int[] stride)
Creates an ndarray with the specified shapeINDArray
create(int[] data, int[] shape, int[] stride, char order, long offset)
INDArray
create(int[] ints, int[] ints1, int[] stride, long offset)
INDArray
create(int[] shape, int[] stride, long offset)
Creates an ndarray with the specified shapeINDArray
create(int[] shape, int[] stride, long offset, char ordering)
INDArray
create(int[] shape, DataType dataType, MemoryWorkspace workspace)
INDArray
create(long columns)
Creates a row vector with the specified number of columnsINDArray
create(long[] shape)
Creates an ndarray with the specified shapeINDArray
create(long[] shape, long[] stride)
INDArray
create(long[] shape, long[] stride, long offset)
INDArray
create(long[] shape, long[] stride, long offset, char ordering)
INDArray
create(long rows, long columns)
Creates an ndarray with the specified shapeINDArray
create(long rows, long columns, char ordering)
INDArray
create(long rows, long columns, int[] stride)
Creates an ndarray with the specified shapeINDArray
create(long rows, long columns, int[] stride, long offset)
Creates an ndarray with the specified shapeabstract INDArray
create(List<INDArray> list, int[] shape)
Creates an ndarray with the specified shapeINDArray
create(DataBuffer buffer, int[] shape, int[] stride, char order, long offset)
DataType
dtype()
Returns the data opType for this ndarrayINDArray
eye(long n)
Create the identity ndarrayINDArray
hstack(@NonNull INDArray... arrs)
Concatenates two matrices horizontally.Lapack
lapack()
Level1
level1()
Return the level 1 blas operationsLevel2
level2()
Return the level 2 blas operationsLevel3
level3()
Return the level 3 blas operationsINDArray
ones(int[] shape)
Create an ndarray of onesINDArray
ones(long columns)
Creates a row vector with the specified number of columnsINDArray
ones(long[] shape)
INDArray
ones(long rows, long columns)
Creates a row vector with the specified number of columnschar
order()
Returns the order for this ndarray for internal data storageINDArray
pullRows(INDArray source, int sourceDimension, int[] indexes)
This method produces concatenated array, that consist from tensors, fetched from source array, against some dimension and specified indexesINDArray
pullRows(INDArray source, int sourceDimension, int[] indexes, char order)
This method produces concatenated array, that consist from tensors, fetched from source array, against some dimension and specified indexesINDArray
rand(char order, int[] shape)
Create a random ndarray with the given shape and orderINDArray
rand(char order, long[] shape)
Create a random ndarray with the given shape and specified output orderINDArray
rand(char order, long rows, long columns)
Create a random (uniform 0-1) NDArray with the specified shape and orderINDArray
rand(int[] shape)
Create a random ndarray with the given shape using the current time as the seedINDArray
rand(int[] shape, double min, double max, Random rng)
INDArray
rand(int[] shape, float min, float max, Random rng)
Generates a random matrix between min and maxINDArray
rand(int[] shape, long seed)
Create a random ndarray with the given shape using the given rngINDArray
rand(int[] shape, Distribution r)
Create a random ndarray with the given shape using the given rngINDArray
rand(int[] shape, Random r)
Create a random ndarray with the given shape using the given rngINDArray
rand(long[] shape)
Create a random ndarray with the given shape using the current time as the seedINDArray
rand(long[] shape, double min, double max, Random rng)
INDArray
rand(long[] shape, float min, float max, Random rng)
INDArray
rand(long[] shape, long seed)
INDArray
rand(long[] shape, Random r)
INDArray
rand(long rows, long columns)
Create a random ndarray with the given shape using the current time as the seedINDArray
rand(long rows, long columns, double min, double max, Random rng)
INDArray
rand(long rows, long columns, float min, float max, Random rng)
Generates a random matrix between min and maxINDArray
rand(long rows, long columns, long seed)
Create a random ndarray with the given shape using the given rngINDArray
rand(long rows, long columns, Random r)
Create a random ndarray with the given shape using the given rngINDArray
randn(char order, int[] shape)
Random normal using the current time stamp as the seedINDArray
randn(char order, long[] shape)
Random normal N(0,1) with the specified shape and orderINDArray
randn(char order, long rows, long columns)
Generate a random normal N(0,1) with the specified order and shapeINDArray
randn(int[] shape)
Random normal N(0,1) with the specified shape andINDArray
randn(int[] shape, long seed)
Random normal using the specified seedINDArray
randn(int[] shape, Random r)
Random normal using the given rngINDArray
randn(long[] shape)
Random normal N(0,1) using the current time stamp as the seedINDArray
randn(long[] shape, long seed)
Random normal using the specified seedINDArray
randn(long[] shape, Random r)
INDArray
randn(long rows, long columns)
Random normal using the current time stamp as the seedINDArray
randn(long rows, long columns, long seed)
Random normal using the specified seedINDArray
randn(long rows, long columns, Random r)
Random normal using the given rngINDArray
reverse(INDArray reverse)
Reverses the passed in matrix such that m[0] becomes m[m.length - 1] etcINDArray
rot(INDArray reverse)
Reverses the passed in matrix such that m[0] becomes m[m.length - 1] etcvoid
rot90(INDArray toRotate)
Rotate a matrix 90 degreesINDArray
scalar(double value)
Create a scalar nd array with the specified value and offsetINDArray
scalar(double value, long offset)
Create a scalar nd array with the specified value and offsetINDArray
scalar(float value)
Create a scalar nd array with the specified value and offsetINDArray
scalar(float value, long offset)
Create a scalar nd array with the specified value and offsetINDArray
scalar(int value, long offset)
Create a scalar nd array with the specified value and offsetINDArray
scalar(Number value)
Create a scalar ndarray with the specified offsetINDArray
scalar(DataType dataType)
Create a scalar nd array with the data type and a default value depending on the data type.void
setDType(DataType dtype)
Sets the data opTypevoid
setOrder(char order)
Sets the order.INDArray
toFlattened(char order, INDArray... matrices)
Flatten all of the ndarrays in to one long vectorINDArray
toFlattened(int length, Iterator<? extends INDArray>... matrices)
Returns a flattened ndarray with all of the elements in each ndarray regardless of dimensionINDArray
toFlattened(Collection<INDArray> matrices)
Returns a vector with all of the elements in every nd array equal to the sum of the lengths of the ndarraysINDArray
toFlattened(INDArray... matrices)
Flatten all of the ndarrays in to one long vectorINDArray
valueArrayOf(int[] shape, double value)
Creates an ndarray with the specified value as the only value in the ndarrayINDArray
valueArrayOf(long[] shape, double value)
INDArray
valueArrayOf(long rows, long columns, double value)
Creates a row vector with the specified number of columnsINDArray
vstack(INDArray... arrs)
Concatenates two matrices vertically.INDArray
zeros(int[] shape)
Create an ndarray of zerosINDArray
zeros(long columns)
Creates a row vector with the specified number of columnsINDArray
zeros(long[] shape)
INDArray
zeros(long rows, long columns)
Creates a row vector with the specified number of columns-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nd4j.linalg.factory.NDArrayFactory
accumulate, average, average, average, average, convertDataEx, convertDataEx, convertDataEx, convertDataEx, convertDataEx, convertToNumpy, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, createBlas, createFromNpyFile, createFromNpyHeaderPointer, createFromNpyPointer, createFromNpzFile, createLapack, createLevel1, createLevel2, createLevel3, createUninitialized, createUninitialized, createUninitialized, createUninitializedDetached, empty, pullRows, pullRows, shuffle, shuffle, shuffle, sort, sort, sortCooIndices, specialConcat, tear, toFlattened
-
-
-
-
Constructor Detail
-
BaseNDArrayFactory
public BaseNDArrayFactory()
-
BaseNDArrayFactory
protected BaseNDArrayFactory(DataType dtype, Character order)
Initialize with the given data opType and ordering The ndarray factory will use this for- Parameters:
dtype
- the data opTypeorder
- the ordering in mem
-
BaseNDArrayFactory
protected BaseNDArrayFactory(DataType dtype, char order)
- Parameters:
dtype
- the data opTypeorder
- the ordering
-
-
Method Detail
-
lapack
public Lapack lapack()
- Specified by:
lapack
in interfaceNDArrayFactory
-
blas
public Blas blas()
Description copied from interface:NDArrayFactory
Return extra blas operations- Specified by:
blas
in interfaceNDArrayFactory
- Returns:
-
level1
public Level1 level1()
Description copied from interface:NDArrayFactory
Return the level 1 blas operations- Specified by:
level1
in interfaceNDArrayFactory
- Returns:
-
level2
public Level2 level2()
Description copied from interface:NDArrayFactory
Return the level 2 blas operations- Specified by:
level2
in interfaceNDArrayFactory
- Returns:
-
level3
public Level3 level3()
Description copied from interface:NDArrayFactory
Return the level 3 blas operations- Specified by:
level3
in interfaceNDArrayFactory
- Returns:
-
setOrder
public void setOrder(char order)
Sets the order. Primarily for testing purposes- Specified by:
setOrder
in interfaceNDArrayFactory
- Parameters:
order
-
-
rand
public INDArray rand(long[] shape, double min, double max, Random rng)
- Specified by:
rand
in interfaceNDArrayFactory
-
rand
public INDArray rand(int[] shape, double min, double max, Random rng)
- Specified by:
rand
in interfaceNDArrayFactory
- Returns:
-
rand
public INDArray rand(long rows, long columns, double min, double max, Random rng)
- Specified by:
rand
in interfaceNDArrayFactory
- Returns:
-
setDType
public void setDType(DataType dtype)
Sets the data opType- Specified by:
setDType
in interfaceNDArrayFactory
- Parameters:
dtype
-
-
create
public INDArray create(int[] shape, DataType dataType, MemoryWorkspace workspace)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
order
public char order()
Returns the order for this ndarray for internal data storage- Specified by:
order
in interfaceNDArrayFactory
- Returns:
- the order (c or f)
-
dtype
public DataType dtype()
Returns the data opType for this ndarray- Specified by:
dtype
in interfaceNDArrayFactory
- Returns:
- the data opType for this ndarray
-
create
public INDArray create(int[] ints, int[] ints1, int[] stride, long offset)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
create
public INDArray create(long rows, long columns, char ordering)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
toFlattened
public INDArray toFlattened(Collection<INDArray> matrices)
Returns a vector with all of the elements in every nd array equal to the sum of the lengths of the ndarrays- Specified by:
toFlattened
in interfaceNDArrayFactory
- Parameters:
matrices
- the ndarrays to getFloat a flattened representation of- Returns:
- the flattened ndarray
-
toFlattened
public INDArray toFlattened(int length, Iterator<? extends INDArray>... matrices)
Description copied from interface:NDArrayFactory
Returns a flattened ndarray with all of the elements in each ndarray regardless of dimension- Specified by:
toFlattened
in interfaceNDArrayFactory
matrices
- the ndarrays to use- Returns:
- a flattened ndarray of the elements in the order of titerating over the ndarray and the linear view of each
-
bilinearProducts
public INDArray bilinearProducts(INDArray curr, INDArray in)
Returns a column vector where each entry is the nth bilinear product of the nth slices of the two tensors.- Specified by:
bilinearProducts
in interfaceNDArrayFactory
-
toFlattened
public INDArray toFlattened(INDArray... matrices)
Description copied from interface:NDArrayFactory
Flatten all of the ndarrays in to one long vector- Specified by:
toFlattened
in interfaceNDArrayFactory
- Parameters:
matrices
- the matrices to flatten- Returns:
- the flattened vector
-
toFlattened
public INDArray toFlattened(char order, INDArray... matrices)
Description copied from interface:NDArrayFactory
Flatten all of the ndarrays in to one long vector- Specified by:
toFlattened
in interfaceNDArrayFactory
matrices
- the matrices to flatten- Returns:
- the flattened vector
-
eye
public INDArray eye(long n)
Create the identity ndarray- Specified by:
eye
in interfaceNDArrayFactory
- Parameters:
n
- the number for the identity- Returns:
-
rot90
public void rot90(INDArray toRotate)
Rotate a matrix 90 degrees- Specified by:
rot90
in interfaceNDArrayFactory
- Parameters:
toRotate
- the matrix to rotate
-
rot
public INDArray rot(INDArray reverse)
Reverses the passed in matrix such that m[0] becomes m[m.length - 1] etc- Specified by:
rot
in interfaceNDArrayFactory
- Parameters:
reverse
- the matrix to reverse- Returns:
- the reversed matrix
-
reverse
public INDArray reverse(INDArray reverse)
Reverses the passed in matrix such that m[0] becomes m[m.length - 1] etc- Specified by:
reverse
in interfaceNDArrayFactory
- Parameters:
reverse
- the matrix to reverse- Returns:
- the reversed matrix
-
arange
public INDArray arange(double begin, double end, double step)
Array of evenly spaced values.- Specified by:
arange
in interfaceNDArrayFactory
- Parameters:
begin
- the begin of the rangeend
- the end of the range- Returns:
- the range vector
-
copy
public void copy(INDArray a, INDArray b)
Copy a to b- Specified by:
copy
in interfaceNDArrayFactory
- Parameters:
a
- the origin matrixb
- the destination matrix
-
rand
public INDArray rand(int[] shape, float min, float max, Random rng)
Generates a random matrix between min and max- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
shape
- the number of rows of the matrixmin
- the minimum numbermax
- the maximum numberrng
- the rng to use- Returns:
- a random matrix of the specified shape and range
-
rand
public INDArray rand(long[] shape, float min, float max, Random rng)
- Specified by:
rand
in interfaceNDArrayFactory
-
rand
public INDArray rand(long rows, long columns, float min, float max, Random rng)
Generates a random matrix between min and max- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
rows
- the number of rows of the matrixcolumns
- the number of columns in the matrixmin
- the minimum numbermax
- the maximum numberrng
- the rng to use- Returns:
- a random matrix of the specified shape and range
-
appendBias
public INDArray appendBias(INDArray... vectors)
Merge the vectors and append a bias. Each vector must be either row or column vectors. An exception is thrown for inconsistency (mixed row and column vectors)- Specified by:
appendBias
in interfaceNDArrayFactory
- Parameters:
vectors
- the vectors to merge- Returns:
- the merged ndarray appended with the bias
-
rand
public INDArray rand(long rows, long columns, Random r)
Create a random ndarray with the given shape using the given rng- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrixr
- the random generator to use- Returns:
- the random ndarray with the specified shape
-
rand
public INDArray rand(long rows, long columns, long seed)
Create a random ndarray with the given shape using the given rng- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
rows
- the number of rows in the matrixcolumns
- the columns of the ndarrayseed
- the seed to use- Returns:
- the random ndarray with the specified shape
-
rand
public INDArray rand(long rows, long columns)
Create a random ndarray with the given shape using the current time as the seed- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrix- Returns:
- the random ndarray with the specified shape
-
rand
public INDArray rand(char order, long rows, long columns)
Create a random (uniform 0-1) NDArray with the specified shape and order- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
order
- Order ('c' or 'f') of the output arrayrows
- Number of rows of the output arraycolumns
- Number of columns of the output array
-
randn
public INDArray randn(long rows, long columns, Random r)
Random normal using the given rng- Specified by:
randn
in interfaceNDArrayFactory
- Parameters:
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrixr
- the random generator to use- Returns:
-
randn
public INDArray randn(long rows, long columns)
Random normal using the current time stamp as the seed- Specified by:
randn
in interfaceNDArrayFactory
- Parameters:
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrix- Returns:
-
randn
public INDArray randn(char order, long rows, long columns)
Generate a random normal N(0,1) with the specified order and shape- Specified by:
randn
in interfaceNDArrayFactory
- Parameters:
order
- Order of the output arrayrows
- the number of rows in the matrixcolumns
- the number of columns in the matrix- Returns:
-
randn
public INDArray randn(long rows, long columns, long seed)
Random normal using the specified seed- Specified by:
randn
in interfaceNDArrayFactory
- Parameters:
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrix- Returns:
-
rand
public INDArray rand(int[] shape, Distribution r)
Create a random ndarray with the given shape using the given rng- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarrayr
- the random generator to use- Returns:
- the random ndarray with the specified shape
-
rand
public INDArray rand(int[] shape, Random r)
Create a random ndarray with the given shape using the given rng- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarrayr
- the random generator to use- Returns:
- the random ndarray with the specified shape
-
rand
public INDArray rand(long[] shape, Random r)
- Specified by:
rand
in interfaceNDArrayFactory
-
rand
public INDArray rand(int[] shape, long seed)
Create a random ndarray with the given shape using the given rng- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarrayseed
- the seed to use- Returns:
- the random ndarray with the specified shape
-
rand
public INDArray rand(long[] shape, long seed)
- Specified by:
rand
in interfaceNDArrayFactory
-
rand
public INDArray rand(int[] shape)
Create a random ndarray with the given shape using the current time as the seed- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray- Returns:
- the random ndarray with the specified shape
-
rand
public INDArray rand(long[] shape)
Description copied from interface:NDArrayFactory
Create a random ndarray with the given shape using the current time as the seed- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray- Returns:
- the random ndarray with the specified shape
-
rand
public INDArray rand(char order, int[] shape)
Create a random ndarray with the given shape and order- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray- Returns:
- the random ndarray with the specified shape
-
rand
public INDArray rand(char order, long[] shape)
Description copied from interface:NDArrayFactory
Create a random ndarray with the given shape and specified output order- Specified by:
rand
in interfaceNDArrayFactory
- Parameters:
order
- the order of the arrayshape
- the shape of the array- Returns:
- the created ndarray
-
randn
public INDArray randn(int[] shape, Random r)
Random normal using the given rng- Specified by:
randn
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarrayr
- the random generator to use- Returns:
-
randn
public INDArray randn(long[] shape, Random r)
- Specified by:
randn
in interfaceNDArrayFactory
-
randn
public INDArray randn(char order, int[] shape)
Random normal using the current time stamp as the seed- Specified by:
randn
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarrayorder
- the order ('c' or 'f') of the output array- Returns:
-
randn
public INDArray randn(char order, long[] shape)
Description copied from interface:NDArrayFactory
Random normal N(0,1) with the specified shape and order- Specified by:
randn
in interfaceNDArrayFactory
- Parameters:
order
- the order ('c' or 'f') of the output arrayshape
- the shape of the ndarray
-
randn
public INDArray randn(int[] shape)
Random normal N(0,1) with the specified shape and- Specified by:
randn
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray- Returns:
-
randn
public INDArray randn(long[] shape)
Description copied from interface:NDArrayFactory
Random normal N(0,1) using the current time stamp as the seed- Specified by:
randn
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray
-
randn
public INDArray randn(int[] shape, long seed)
Random normal using the specified seed- Specified by:
randn
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray- Returns:
-
randn
public INDArray randn(long[] shape, long seed)
Description copied from interface:NDArrayFactory
Random normal using the specified seed- Specified by:
randn
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray- Returns:
-
create
public INDArray create(double[] data)
Creates a row vector with the data- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
data
- the columns of the ndarray- Returns:
- the created ndarray
-
create
public INDArray create(float[] data)
Creates a row vector with the data- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
data
- the columns of the ndarray- Returns:
- the created ndarray
-
create
public INDArray create(long columns)
Creates a row vector with the specified number of columns- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
columns
- the columns of the ndarray- Returns:
- the created ndarray
-
zeros
public INDArray zeros(long rows, long columns)
Creates a row vector with the specified number of columns- Specified by:
zeros
in interfaceNDArrayFactory
- Parameters:
rows
- the rows of the ndarraycolumns
- the columns of the ndarray- Returns:
- the created ndarray
-
pullRows
public INDArray pullRows(INDArray source, int sourceDimension, int[] indexes, char order)
This method produces concatenated array, that consist from tensors, fetched from source array, against some dimension and specified indexes- Specified by:
pullRows
in interfaceNDArrayFactory
- Parameters:
source
- source tensorsourceDimension
- dimension of source tensorindexes
- indexes from source arrayorder
- order for result array- Returns:
-
pullRows
public INDArray pullRows(INDArray source, int sourceDimension, int[] indexes)
This method produces concatenated array, that consist from tensors, fetched from source array, against some dimension and specified indexes- Specified by:
pullRows
in interfaceNDArrayFactory
- Parameters:
source
- source tensorsourceDimension
- dimension of source tensorindexes
- indexes from source array- Returns:
-
zeros
public INDArray zeros(long columns)
Creates a row vector with the specified number of columns- Specified by:
zeros
in interfaceNDArrayFactory
- Parameters:
columns
- the columns of the ndarray- Returns:
- the created ndarray
-
valueArrayOf
public INDArray valueArrayOf(int[] shape, double value)
Creates an ndarray with the specified value as the only value in the ndarray- Specified by:
valueArrayOf
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarrayvalue
- the value to assign- Returns:
- the created ndarray
-
valueArrayOf
public INDArray valueArrayOf(long[] shape, double value)
- Specified by:
valueArrayOf
in interfaceNDArrayFactory
-
create
public INDArray create(int[] shape, int[] stride, long offset, char ordering)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
valueArrayOf
public INDArray valueArrayOf(long rows, long columns, double value)
Creates a row vector with the specified number of columns- Specified by:
valueArrayOf
in interfaceNDArrayFactory
- Parameters:
rows
- the number of rows in the matrixcolumns
- the columns of the ndarrayvalue
- the value to assign- Returns:
- the created ndarray
-
ones
public INDArray ones(long rows, long columns)
Creates a row vector with the specified number of columns- Specified by:
ones
in interfaceNDArrayFactory
- Parameters:
rows
- the number of rows in the matrixcolumns
- the columns of the ndarray- Returns:
- the created ndarray
-
ones
public INDArray ones(long columns)
Creates a row vector with the specified number of columns- Specified by:
ones
in interfaceNDArrayFactory
- Parameters:
columns
- the columns of the ndarray- Returns:
- the created ndarray
-
create
public INDArray create(float[] data, int[] shape, char ordering)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
concat
public INDArray concat(int dimension, INDArray... toConcat)
concatenate ndarrays along a dimension- Specified by:
concat
in interfaceNDArrayFactory
- Parameters:
dimension
- the dimension to concatenate alongtoConcat
- the ndarrays to concatenate- Returns:
- the concatenate ndarrays
-
hstack
public INDArray hstack(@NonNull @NonNull INDArray... arrs)
Concatenates two matrices horizontally. Matrices must have identical numbers of rows.- Specified by:
hstack
in interfaceNDArrayFactory
- Parameters:
arrs
-
-
vstack
public INDArray vstack(INDArray... arrs)
Concatenates two matrices vertically. Matrices must have identical numbers of columns.- Specified by:
vstack
in interfaceNDArrayFactory
- Parameters:
arrs
-
-
zeros
public INDArray zeros(int[] shape)
Create an ndarray of zeros- Specified by:
zeros
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray- Returns:
- an ndarray with ones filled in
-
zeros
public INDArray zeros(long[] shape)
- Specified by:
zeros
in interfaceNDArrayFactory
-
ones
public INDArray ones(int[] shape)
Create an ndarray of ones- Specified by:
ones
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray- Returns:
- an ndarray with ones filled in
-
ones
public INDArray ones(long[] shape)
- Specified by:
ones
in interfaceNDArrayFactory
-
create
public INDArray create(float[] data, long rows, long columns, int[] stride, long offset)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
data
- the data to use with the ndarrayrows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarray- Returns:
- the instance
-
create
public abstract INDArray create(float[] data, int[] shape, int[] stride, long offset)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarray- Returns:
- the instance
-
create
public INDArray create(double[] data, int[] shape)
Create an ndrray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
data
- the data to use with tne ndarrayshape
- the shape of the ndarray- Returns:
- the created ndarray
-
create
public INDArray create(float[] data, int[] shape)
Create an ndrray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
data
- the data to use with tne ndarrayshape
- the shape of the ndarray- Returns:
- the created ndarray
-
create
public INDArray create(float[] data, long[] shape)
- Specified by:
create
in interfaceNDArrayFactory
-
create
public INDArray create(double[] data, long[] shape)
- Specified by:
create
in interfaceNDArrayFactory
-
create
public INDArray create(double[] data, long rows, long columns, int[] stride, long offset)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
data
- the data to use with tne ndarrayrows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarray- Returns:
- the instance
-
create
public abstract INDArray create(double[] data, int[] shape, int[] stride, long offset)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarray- Returns:
- the instance
-
create
public abstract INDArray create(List<INDArray> list, int[] shape)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray- Returns:
- the instance
-
create
public INDArray create(long rows, long columns, int[] stride, long offset)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
rows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarray- Returns:
- the instance
-
create
public INDArray create(int[] shape, int[] stride, long offset)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarray- Returns:
- the instance
-
create
public INDArray create(long[] shape, long[] stride, long offset)
- Specified by:
create
in interfaceNDArrayFactory
-
scalar
public INDArray scalar(DataType dataType)
Description copied from interface:NDArrayFactory
Create a scalar nd array with the data type and a default value depending on the data type. Generally this will be an empty string for UTF8 or 0.0 for numerical values, or true for booleans.- Specified by:
scalar
in interfaceNDArrayFactory
- Parameters:
dataType
- the dataType of the scalar * @return the scalar nd array
-
create
public INDArray create(long rows, long columns, int[] stride)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
rows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarray- Returns:
- the instance
-
create
public INDArray create(long[] shape, long[] stride)
- Specified by:
create
in interfaceNDArrayFactory
-
create
public INDArray create(long[] shape, long[] stride, long offset, char ordering)
- Specified by:
create
in interfaceNDArrayFactory
-
create
public INDArray create(int[] shape, int[] stride)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarraystride
- the stride for the ndarray- Returns:
- the instance
-
create
public INDArray create(long rows, long columns)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
rows
- the rows of the ndarraycolumns
- the columns of the ndarray- Returns:
- the instance
-
create
public INDArray create(long[] shape)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray- Returns:
- the instance
-
create
public INDArray create(int[] shape)
Creates an ndarray with the specified shape- Specified by:
create
in interfaceNDArrayFactory
- Parameters:
shape
- the shape of the ndarray- Returns:
- the instance
-
scalar
public INDArray scalar(float value, long offset)
Create a scalar nd array with the specified value and offset- Specified by:
scalar
in interfaceNDArrayFactory
- Parameters:
value
- the value of the scalaroffset
- the offset of the ndarray- Returns:
- the scalar nd array
-
scalar
public INDArray scalar(double value, long offset)
Create a scalar nd array with the specified value and offset- Specified by:
scalar
in interfaceNDArrayFactory
- Parameters:
value
- the value of the scalaroffset
- the offset of the ndarray- Returns:
- the scalar nd array
-
scalar
public INDArray scalar(int value, long offset)
Create a scalar nd array with the specified value and offset- Specified by:
scalar
in interfaceNDArrayFactory
- Parameters:
value
- the value of the scalaroffset
- the offset of the ndarray- Returns:
- the scalar nd array
-
scalar
public INDArray scalar(Number value)
Create a scalar ndarray with the specified offset- Specified by:
scalar
in interfaceNDArrayFactory
- Parameters:
value
- the value to initialize the scalar with- Returns:
- the created ndarray
-
scalar
public INDArray scalar(double value)
Create a scalar nd array with the specified value and offset- Specified by:
scalar
in interfaceNDArrayFactory
- Parameters:
value
- the value of the scalar- Returns:
- the scalar nd array
-
scalar
public INDArray scalar(float value)
Description copied from interface:NDArrayFactory
Create a scalar nd array with the specified value and offset- Specified by:
scalar
in interfaceNDArrayFactory
- Parameters:
value
- the value of the scalar = * @return the scalar nd array
-
create
public INDArray create(float[] data, int[] shape, long offset)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
create
public abstract INDArray create(float[] data, long[] shape, long[] stride, char order, DataType dataType, MemoryWorkspace workspace)
- Specified by:
create
in interfaceNDArrayFactory
-
create
public INDArray create(float[] data, char order)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
create
public INDArray create(float[] data, int[] shape, int[] stride, char order, long offset)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
create
public INDArray create(double[] data, char order)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
create
public INDArray create(double[] data, int[] shape, int[] stride, char order, long offset)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
create
public INDArray create(DataBuffer buffer, int[] shape, int[] stride, char order, long offset)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
create
public INDArray create(int[] data, int[] shape, int[] stride, char order, long offset)
- Specified by:
create
in interfaceNDArrayFactory
- Returns:
-
-