Package org.nd4j.linalg.api.ndarray
Interface INDArray
-
- All Superinterfaces:
AutoCloseable
,Serializable
- All Known Implementing Classes:
BaseNDArray
public interface INDArray extends Serializable, AutoCloseable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description INDArray
add(Number n)
Scalar addition (cloning)INDArray
add(Number n, INDArray result)
Addition of this ndarray.INDArray
add(INDArray other)
Element-wise copy addition of two NDArraysINDArray
add(INDArray other, INDArray result)
Element-wise copy addition of two NDArraysINDArray
addColumnVector(INDArray columnVector)
Addition of a column vector (copy)INDArray
addi(Number n)
In place scalar additionINDArray
addi(Number n, INDArray result)
In place additionINDArray
addi(INDArray other)
in place (element wise) addition of two NDArraysINDArray
addi(INDArray other, INDArray result)
in place (element wise) addition of two NDArraysINDArray
addiColumnVector(INDArray columnVector)
In place addition of a column vectorINDArray
addiRowVector(INDArray rowVector)
In place addition of a row vectorINDArray
addRowVector(INDArray rowVector)
Addition of a row vector (copy)boolean
all()
This method checks if all elements within this array are non-zero (or true, in case of boolean)INDArray
amax(int... dimension)
Returns the absolute overall max of this ndarray along given dimensionsNumber
amaxNumber()
Returns maximum (absolute) value in this INDArrayINDArray
amean(int... dimension)
Returns the absolute overall mean of this ndarrayNumber
ameanNumber()
Returns the absolute overall mean of this ndarrayINDArray
amin(int... dimension)
Returns minimum (absolute) value in this INDArray, along the specified dimensionsNumber
aminNumber()
Returns absolute min value in this INDArrayboolean
any()
This method checks if any of the elements within this array are non-zero (or true, in case of boolean)INDArray
argMax(int... dimension)
This method returns index of highest value along specified dimension(s)INDArray
assign(boolean value)
Set all entries of the ndarray to the specified valueINDArray
assign(Number value)
Set all entries of the ndarray to the specified valueINDArray
assign(INDArray arr)
Assign all of the elements in the given ndarray to this ndarrayINDArray
assignIf(INDArray arr, Condition condition)
Assign all elements from given ndarray that are matching given condition, ndarray to this ndarrayINDArray
broadcast(long... shape)
Broadcasts this ndarray to be the specified shapeINDArray
broadcast(INDArray result)
Broadcasts this ndarray to be the specified shapeINDArray
castTo(DataType dataType)
This method cast elements of this INDArray to new data typevoid
close()
This method releases exclusive off-heap resources uses by this INDArray instance.boolean
closeable()
This method checks, if this INDArray instalce can use close() methodint
columns()
Returns the number of columns in this matrix (throws exception if not 2d)INDArray
cond(Condition condition)
Returns a binary INDArray with value 'true' if the element matches the specified condition and 'false' otherwiseINDArray
cumsum(int dimension)
Returns the cumulative sum along a dimension.INDArray
cumsumi(int dimension)
Returns the cumulative sum along a dimension.DataBuffer
data()
Returns a linear double array representation of this ndarrayDataType
dataType()
This method returns dtype for this INDArrayINDArray
detach()
This method detaches INDArray from Workspace, returning copy.INDArray
dimShuffle(Object[] rearrange, int[] newOrder, boolean[] broadCastable)
Dimshuffle: an extension of permute that adds the ability to broadcast various dimensions.INDArray
dimShuffle(Object[] rearrange, long[] newOrder, boolean[] broadCastable)
double
distance1(INDArray other)
Returns the (1-norm) distance.double
distance2(INDArray other)
Returns the (euclidean) distance.INDArray
div(Number n)
Division by a numberINDArray
div(Number n, INDArray result)
Division if ndarray by numberINDArray
div(INDArray other)
Copy (element wise) division of two NDArraysINDArray
div(INDArray other, INDArray result)
copy (element wise) division of two NDArraysINDArray
divColumnVector(INDArray columnVector)
Division of a column vector (copy)INDArray
divi(Number n)
In place scalar divisionINDArray
divi(Number n, INDArray result)
In place division of this ndarrayINDArray
divi(INDArray other)
in place (element wise) division of two NDArraysINDArray
divi(INDArray other, INDArray result)
in place (element wise) division of two NDArraysINDArray
diviColumnVector(INDArray columnVector)
In place division of a column vectorINDArray
diviRowVector(INDArray rowVector)
In place division of a row vectorINDArray
divRowVector(INDArray rowVector)
Division of a row vector (copy)INDArray
dup()
Returns a copy of this ndarrayINDArray
dup(char order)
Returns a copy of this ndarray, where the returned ndarray has the specified orderObject
element()
Returns a scalar (individual element) of a scalar ndarrayint
elementWiseStride()
Element wise strideINDArray
entropy(int... dimension)
Returns entropy value for this INDArray along specified dimension(s)Number
entropyNumber()
Returns entropy value for this INDArrayINDArray
eps(Number other)
Returns the binary ndarray for "Epsilon equals" comparison.INDArray
eps(INDArray other)
Returns the binary ndarray for "Epsilon equals" comparison.INDArray
eq(Number other)
Returns the binary ndarray for "Equals" comparison.INDArray
eq(INDArray other)
Returns the binary ndarray for "Equals" comparison.boolean
equalShapes(INDArray other)
This method checks 2 INDArrays for equal shapes.
Shapes are considered equal if:
(a) Both arrays have equal rank, and
(b) size(0)...size(rank()-1) are equal for both arraysboolean
equalsWithEps(Object o, double eps)
This method checks 2 INDArrays equality with given epsINDArray
fmod(Number denominator)
remainder of division by scalar.INDArray
fmod(Number denominator, INDArray result)
remainder of division by scalar.INDArray
fmod(INDArray denominator)
remainder of divisionINDArray
fmod(INDArray denominator, INDArray result)
remainder of divisionINDArray
fmodi(Number denominator)
In place fmodINDArray
fmodi(INDArray denominator)
In place fmodINDArray
get(INDArray indices)
Get the elements from this ndarray based on the specified indicesINDArray
get(INDArrayIndex... indexes)
Returns a subset of this array based on the specified indexesINDArray
getColumn(long i)
Returns the specified column.INDArray
getColumn(long i, boolean keepDim)
Returns the specified column.INDArray
getColumns(int... columns)
Get an INDArray comprised of the specified columns only.double
getDouble(int... indices)
Get a double value at the specified indices.double
getDouble(long i)
Get the double value at the specified linear index in the arraydouble
getDouble(long... indices)
SeegetDouble(int[])
double
getDouble(long i, long j)
Get the double value at the specified indices.double
getDoubleUnsafe(long offset)
Get a double at the given linear offset unsafe, without checks.float
getFloat(int... indices)
Returns the elements at the specified indicesfloat
getFloat(long i)
Return the item at the linear index ifloat
getFloat(long... indices)
SeegetFloat(int...)
float
getFloat(long i, long j)
Return the item at row i column j Note that this is the same as calling getScalar(new int[]{i,j}long
getId()
A unique ID for the INDArray object instance.int
getInt(int... indices)
Get an integer value at the specified indices.int
getLeadingOnes()
Get the number of leading ones in the array shape.long
getLong(long index)
Get a long value at the specified index.long
getLong(long... indices)
Get a long value at the specified indices.Number
getNumber(long index)
Get the numeric value at the specified index.Number
getNumber(long... indices)
Get a numeric value at the specified indices.INDArray
getRow(long i)
Returns the specified row as a 1D vector.INDArray
getRow(long i, boolean keepDim)
Returns the specified row.INDArray
getRows(int... rows)
Get an INDArray comprised of the specified rows only.INDArray
getScalar(int... indices)
Returns the elements at the specified indicesINDArray
getScalar(long i)
Returns the element at the specified indexINDArray
getScalar(long... indices)
SeegetScalar(int[])
INDArray
getScalar(long row, long column)
Returns the element at the specified row/columnString
getString(long index)
Get string value at given index.int
getTrailingOnes()
Get the number of trailing ones in the array shape.INDArray
getWhere(Number comp, Condition condition)
Boolean indexing: Return the element if it fulfills the condition in result arrayINDArray
getWhere(INDArray comp, Condition condition)
Boolean indexing: Return the element if it fulfills the condition in result arrayINDArray
gt(Number other)
Returns the binary ndarray for "Greater" comparison.INDArray
gt(INDArray other)
Returns the binary ndarray for "Greater Than" comparison.INDArray
gte(Number other)
Returns binary ndarray for "Greter or equals" comparison.boolean
isAttached()
This method returns True, if this INDArray instance is attached to some Workspace.boolean
isB()
This method checks if this INDArray instance has boolean typeboolean
isColumnVector()
Returns true if the number of columns is 1boolean
isColumnVectorOrScalar()
Returns true if the number of columns is 1boolean
isCompressed()
Check if this array is compressed.boolean
isEmpty()
This method returns true if this INDArray is special case: no-value INDArrayINDArray
isInfinite()
Returns the binary NDArray with value true where this array's entries are infinite, or false where they are not infiniteboolean
isInScope()
This method checks, if given attached INDArray is still in scope of its parent Workspace PLEASE NOTE: if this INDArray isn't attached to any Workspace, this method will return trueboolean
isMatrix()
Returns true if this ndarray is a matrixINDArray
isNaN()
Returns the binary NDArray with value true where this array's entries are NaN, or false where they are not infiniteboolean
isR()
This method checks if this INDArray instance is one of Real typesboolean
isRowVector()
Returns true if the number of rows is 1boolean
isRowVectorOrScalar()
Returns true if the number of rows is 1boolean
isS()
This method checks if this INDArray instance has String typeboolean
isScalar()
Returns true if this ndarray is a scalarboolean
isSparse()
Check if this array is sparseboolean
isSquare()
Returns whether the matrix has the same rows and columnsboolean
isVector()
Returns true if this ndarray is a vectorboolean
isVectorOrScalar()
Returns true if this ndarray is a vector or scalarboolean
isView()
Check if this array is a view or not.boolean
isZ()
This method checks if this INDArray instance is one of integer typeslong
length()
Returns the total number of elements in the ndarrayINDArray
leverage()
This method detaches INDArray from current Workspace, and attaches it to Workspace above, if any.INDArray
leverageOrDetach(String id)
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id, if a workspace with the given ID is open and active.INDArray
leverageTo(String id)
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id - if a workspace with that ID exists.INDArray
leverageTo(String id, boolean enforceExistence)
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id.INDArray
like()
This method returns empty array with the same dtype/order/shape as this onelong
linearIndex(long i)
Get the linear index of the data in to the arrayINDArray
logEntropy(int... dimension)
Returns log entropy value for this INDArray along specified dimension(s)Number
logEntropyNumber()
Returns log entropy value for this INDArrayINDArray
lt(Number other)
Returns the binary ndarray for "Less" comparison.INDArray
lt(INDArray other)
Returns the binary ndarray for "Less" comparison.INDArray
lte(Number other)
Returns the binary ndarray for "Less or equals" comparison.void
markAsCompressed(boolean reallyCompressed)
This method marks INDArray instance as compressed PLEASE NOTE: Do not use this method unless you 100% have toINDArray
match(Number comp, Condition condition)
Returns a maskINDArray
match(INDArray comp, Condition condition)
Return a mask on whether each element matches the given conditionINDArray
max(boolean keepDims, int... dimension)
Returns the overall max of this ndarray along given dimensionsINDArray
max(int... dimension)
Returns the overall max of this ndarray along given dimensionsNumber
maxNumber()
Returns maximum value in this INDArrayINDArray
mean(boolean keepDims, int... dimension)
Returns the overall mean of this ndarrayINDArray
mean(int... dimension)
Returns the overall mean of this ndarrayINDArray
mean(INDArray result, boolean keepDims, int... dimension)
Returns the overall mean of this ndarrayINDArray
mean(INDArray result, int... dimension)
Returns the overall mean of this ndarrayNumber
meanNumber()
Returns the overall mean of this ndarrayINDArray
median(int... dimension)
This method returns median along given dimension(s)Number
medianNumber()
This method returns median value for this INDArrayINDArray
migrate()
This method pulls this INDArray into current Workspace.INDArray
migrate(boolean detachOnNoWs)
This method pulls this INDArray into current Workspace, or optionally detaches if no workspace is present.
That is:
If current workspace is present/active, INDArray is migrated to it.
If no current workspace is present/active, one of two things occur: 1.INDArray
min(boolean keepDims, int... dimension)
Returns the overall min of this ndarrayINDArray
min(int... dimension)
Returns the overall min of this ndarrayNumber
minNumber()
Returns min value in this INDArrayINDArray
mmul(INDArray other)
Perform a copy matrix multiplicationINDArray
mmul(INDArray other, char resultOrder)
Perform a copy matrix multiplicationINDArray
mmul(INDArray other, MMulTranspose mMulTranspose)
Perform a copy matrix multiplicationINDArray
mmul(INDArray other, INDArray result)
Perform an copy matrix multiplicationINDArray
mmul(INDArray other, INDArray result, MMulTranspose mMulTranspose)
Perform an copy matrix multiplicationINDArray
mmuli(INDArray other)
Perform an inplace matrix multiplicationINDArray
mmuli(INDArray other, MMulTranspose transpose)
Perform an copy matrix multiplicationINDArray
mmuli(INDArray other, INDArray result)
Perform an inplace matrix multiplicationINDArray
mmuli(INDArray other, INDArray result, MMulTranspose transpose)
Perform an in place matrix multiplicationINDArray
mul(Number n)
Scalar multiplication (copy)INDArray
mul(Number n, INDArray result)
Multiplication of ndarray.INDArray
mul(INDArray other)
copy (element wise) multiplication of two NDArraysINDArray
mul(INDArray other, INDArray result)
copy (element wise) multiplication of two NDArraysINDArray
mulColumnVector(INDArray columnVector)
Multiplication of a column vector (copy)INDArray
muli(Number n)
In place scalar multiplicationINDArray
muli(Number n, INDArray result)
In place multiplication of this ndarrayINDArray
muli(INDArray other)
in place (element wise) multiplication of two NDArraysINDArray
muli(INDArray other, INDArray result)
in place (element wise) multiplication of two NDArraysINDArray
muliColumnVector(INDArray columnVector)
In place multiplication of a column vectorINDArray
muliRowVector(INDArray rowVector)
In place multiplication of a row vectorINDArray
mulRowVector(INDArray rowVector)
Multiplication of a row vector (copy)INDArray
neg()
Returns the ndarray negative (cloned)INDArray
negi()
In place setting of the negative version of this ndarrayINDArray
neq(Number other)
Returns the binary ndarray for "Not equals" comparison.INDArray
neq(INDArray other)
Returns the binary ndarray for "Not equals" comparison.boolean
none()
This method checks if any of the elements within this array are non-zero (or true, in case of boolean)INDArray
norm1(boolean keepDims, int... dimension)
Returns the norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) along the specified dimensionINDArray
norm1(int... dimension)
Returns the norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) along the specified dimensionNumber
norm1Number()
Calculate and return norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) for the entire arrayINDArray
norm2(boolean keepDims, int... dimension)
Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)INDArray
norm2(int... dimension)
Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)Number
norm2Number()
Return the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) for the entire arrayINDArray
normmax(boolean keepDims, int... dimension)
Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)INDArray
normmax(int... dimension)
Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)Number
normmaxNumber()
Return the max norm (aka infinity norm, equal to the maximum absolute value) for the entire arraylong
offset()
Returns the start of where the ndarray is for the underlying datachar
ordering()
Return the ordering (fortran or c 'f' and 'c' respectively) of this ndarraylong
originalOffset()
Returns the start of where the ndarray is for the original data bufferINDArray
percentile(Number percentile, int... dimension)
This method returns percentile along given dimension(s)Number
percentileNumber(Number percentile)
This method returns percentile value for this INDArrayINDArray
permute(int... rearrange)
See: http://www.mathworks.com/help/matlab/ref/permute.htmlINDArray
permutei(int... rearrange)
An in-place version of permute.INDArray
prod(boolean keepDims, int... dimension)
Returns the product along a given dimensionINDArray
prod(int... dimension)
Returns the product along a given dimensionNumber
prodNumber()
Calculate the product of all values in the arrayINDArray
put(int[] indices, INDArray element)
Inserts the element at the specified indexINDArray
put(int i, int j, Number element)
Inserts the element at the specified indexINDArray
put(int i, int j, INDArray element)
Inserts the element at the specified indexINDArray
put(int i, INDArray element)
Inserts the element at the specified indexINDArray
put(INDArray indices, INDArray element)
Put element in to the indices denoted by the indices ndarray.INDArray
put(INDArrayIndex[] indices, Number element)
Put the elements of the ndarray in to the specified indicesINDArray
put(INDArrayIndex[] indices, INDArray element)
Put the elements of the ndarray in to the specified indicesINDArray
putColumn(int column, INDArray toPut)
Insert a column in to this array Will throw an exception if this ndarray is not a matrixINDArray
putiColumnVector(INDArray columnVector)
In place assignment of a column vectorINDArray
putiRowVector(INDArray rowVector)
in place assignment of row vector, to each row of this arrayINDArray
putRow(long row, INDArray toPut)
Insert a row in to this array Will throw an exception if this ndarray is not a matrixINDArray
putScalar(int[] i, double value)
Insert the item at the specified indicesINDArray
putScalar(int[] indexes, float value)
Put the specified float value at the specified indices in this arrayINDArray
putScalar(int[] indexes, int value)
Put the specified integer value at the specified indices in this arrayINDArray
putScalar(long[] i, double value)
INDArray
putScalar(long[] i, float value)
INDArray
putScalar(long[] i, int value)
INDArray
putScalar(long i, double value)
Insert the number linearly in to the ndarrayINDArray
putScalar(long i, float value)
Insert a scalar float at the specified indexINDArray
putScalar(long i, int value)
Insert a scalar int at the specified indexINDArray
putScalar(long row, long col, double value)
Insert the value at the specified indices, in a 2d (rank 2) NDArray
Equivalent toputScalar(int[], double)
but avoids int[] creationINDArray
putScalar(long dim0, long dim1, long dim2, double value)
Insert the value at the specified indices, in a 3d (rank 3) NDArray
Equivalent toputScalar(int[], double)
but avoids int[] creationINDArray
putScalar(long dim0, long dim1, long dim2, long dim3, double value)
Insert the value at the specified indices, in a 4d (rank 4) NDArray
Equivalent toputScalar(int[], double)
but avoids int[] creationINDArray
putScalarUnsafe(long offset, double value)
Insert a scalar at the given linear offsetINDArray
putSlice(int slice, INDArray put)
Assigns the given matrix (put) to the specified sliceINDArray
putWhere(Number comp, Number put, Condition condition)
Assign the element according to the comparison arrayINDArray
putWhere(Number comp, INDArray put, Condition condition)
Assign the element according to the comparison arrayINDArray
putWhere(INDArray comp, INDArray put, Condition condition)
Assign the element according to the comparison arrayINDArray
putWhereWithMask(INDArray mask, Number put)
Use a pre computed mask for assigning arraysINDArray
putWhereWithMask(INDArray mask, INDArray put)
Use a pre computed mask for assigning arraysint
rank()
Returns the rank of the ndarray (the number of dimensions).INDArray
ravel()
Returns a flattened version (row vector) of this ndarrayINDArray
ravel(char order)
Returns a flattened version (row vector) of this ndarrayINDArray
rdiv(Number n)
Reverse division with a scalar - i.e., (n / thisArrayValues)INDArray
rdiv(Number n, INDArray result)
Reverse division (number / ndarray)INDArray
rdiv(INDArray other)
Reverse division, elements wise.INDArray
rdiv(INDArray other, INDArray result)
Reverse divisionINDArray
rdivColumnVector(INDArray columnVector)
Reverse division of a column vector (copy)INDArray
rdivi(Number n)
In place reverse division - i.e., (n / thisArrayValues)INDArray
rdivi(Number n, INDArray result)
Reverse in place divisionINDArray
rdivi(INDArray other)
Reverse divsion (in place).INDArray
rdivi(INDArray other, INDArray result)
Reverse division (in-place)INDArray
rdiviColumnVector(INDArray columnVector)
In place reverse divison of a column vectorINDArray
rdiviRowVector(INDArray rowVector)
In place reverse division of a column vectorINDArray
rdivRowVector(INDArray rowVector)
Reverse division of a column vector (copy)INDArray
remainder(Number denominator)
The scalar remainderINDArray
remainder(Number denominator, INDArray result)
The scalar remainderINDArray
remainder(INDArray denominator)
Remainder operatorINDArray
remainder(INDArray denominator, INDArray result)
Remainder operatorINDArray
remainderi(Number denominator)
In place remainderINDArray
remainderi(INDArray denominator)
In place remainderINDArray
repeat(int dimension, long... repeats)
Repeat elements along a specified dimension.INDArray
replaceWhere(INDArray arr, Condition condition)
Replaces all elements in this ndarray that are matching give condition, with corresponding elements from given arrayINDArray
repmat(int... shape)
Deprecated.INDArray
repmat(long... shape)
Replicate and tile array to fill out to the given shape See: https://github.com/numpy/numpy/blob/master/numpy/matlib.py#L310-L358INDArray
reshape(char order, boolean enforceView, long... newShape)
Reshapes the ndarray (note: it's not possible to change the length of the ndarray).INDArray
reshape(char order, int... newShape)
Reshapes the ndarray (can't change the length of the ndarray).INDArray
reshape(char order, int rows, int columns)
Reshapes the ndarray (can't change the length of the ndarray).INDArray
reshape(char order, long... newShape)
Reshapes the ndarray (can't change the length of the ndarray).INDArray
reshape(int[] shape)
Seereshape(long[])
INDArray
reshape(long... newShape)
Reshapes the ndarray (can't change the length of the ndarray).INDArray
reshape(long rows, long columns)
Reshapes the ndarray (can't change the length of the ndarray).int
rows()
Returns the number of rows in this matrix (throws exception if not 2d)INDArray
rsub(Number n)
Reverse subtraction with duplicates - i.e., (n - thisArrayValues)INDArray
rsub(Number n, INDArray result)
Reverse subtractionINDArray
rsub(INDArray other)
Element-wise reverse subtraction (copy op).INDArray
rsub(INDArray other, INDArray result)
Reverse subtractionINDArray
rsubColumnVector(INDArray columnVector)
Reverse subtraction of a column vector (copy)INDArray
rsubi(Number n)
Reverse subtraction in place - i.e., (n - thisArrayValues)INDArray
rsubi(Number n, INDArray result)
Reverse in place subtractionINDArray
rsubi(INDArray other)
Element-wise reverse subtraction (in the place op) - i.e., other - thisINDArray
rsubi(INDArray other, INDArray result)
Reverse subtraction (in-place)INDArray
rsubiColumnVector(INDArray columnVector)
In place reverse subtraction of a column vectorINDArray
rsubiRowVector(INDArray rowVector)
In place reverse subtraction of a row vectorINDArray
rsubRowVector(INDArray rowVector)
Reverse subtraction of a row vector (copy)Number
scan(Condition condition)
This method takes boolean condition, and returns number of elements matching this conditionvoid
setCloseable(boolean closeable)
Mainly for overriding closeable in specific situations where a user does not want an ndarray closed.void
setData(DataBuffer data)
Set the data for this ndarray.void
setOrder(char order)
Set the orderingvoid
setShapeAndStride(int[] shape, int[] stride)
Shape and stride setterINDArray
shannonEntropy(int... dimension)
Returns Shannon entropy value for this INDArray along specified dimension(s)Number
shannonEntropyNumber()
Returns non-normalized Shannon entropy value for this INDArraylong[]
shape()
Returns the shape of this ndarrayLongShapeDescriptor
shapeDescriptor()
Returns shape descriptor of this ndarrayLongBuffer
shapeInfo()
Shape infoDataBuffer
shapeInfoDataBuffer()
Shape infolong[]
shapeInfoJava()
This method returns shapeInformation as jvm long arrayString
shapeInfoToString()
Returns the shape information debugging informationlong
size(int dimension)
Returns the size along a specified dimensionINDArray
slice(long i)
Returns the specified slice of this ndarrayINDArray
slice(long i, int dimension)
Returns the slice of this from the specified dimensionlong
slices()
Returns the number of slices in this ndarrayvoid
sliceVectors(List<INDArray> list)
Flattens the array for linear indexing in list.double
squaredDistance(INDArray other)
Returns the square of the Euclidean distance.INDArray
std(boolean biasCorrected, boolean keepDims, int... dimension)
Standard deviation of an ndarray along a dimensionINDArray
std(boolean biasCorrected, int... dimension)
Standard deviation of an ndarray along a dimensionINDArray
std(int... dimension)
Standard deviation of an INDArray along one or more dimensionsNumber
stdNumber()
Calculate the standard deviation for the entire arrayNumber
stdNumber(boolean biasCorrected)
Calculate the standard deviation for the entire array, specifying whether it is bias corrected or notlong[]
stride()
Returns the stride of this ndarrayint
stride(int dimension)
Calculate the stride along a particular dimensionINDArray
sub(Number n)
Scalar subtraction (copied)INDArray
sub(Number n, INDArray result)
Subtraction of this ndarrayINDArray
sub(INDArray other)
copy subtraction of two NDArraysINDArray
sub(INDArray other, INDArray result)
copy subtraction of two NDArraysINDArray
subColumnVector(INDArray columnVector)
Subtraction of a column vector (copy)INDArray
subi(Number n)
In place scalar subtractionINDArray
subi(Number n, INDArray result)
In place subtraction of this ndarrayINDArray
subi(INDArray other)
in place (element wise) subtraction of two NDArraysINDArray
subi(INDArray other, INDArray result)
in place (element wise) subtraction of two NDArraysINDArray
subiColumnVector(INDArray columnVector)
In place subtraction of a column vectorINDArray
subiRowVector(INDArray rowVector)
In place subtraction of a row vectorINDArray
subRowVector(INDArray rowVector)
Subtraction of a row vector (copy)INDArray
sum(boolean keepDims, int... dimension)
Returns the sum along the last dimension of this ndarrayINDArray
sum(int... dimension)
Returns the sum along the last dimension of this ndarrayINDArray
sum(INDArray result, boolean keepDims, int... dimension)
Returns the sum along the last dimension of this ndarrayINDArray
sum(INDArray result, int... dimension)
Returns the sum along the last dimension of this ndarrayNumber
sumNumber()
Sum the entire arrayINDArray
swapAxes(int dimension, int with)
Mainly here for people coming from numpy.INDArray
tensorAlongDimension(long index, int... dimension)
Get the vector along a particular dimensionlong
tensorsAlongDimension(int... dimension)
Returns the number of possible vectors for a given dimensiondouble[][]
toDoubleMatrix()
Convert this ndarray to a 2d double matrix.double[]
toDoubleVector()
Convert this ndarray to a 1d double matrix.int
toFlatArray(com.google.flatbuffers.FlatBufferBuilder builder)
Add anINDArray
to flatbuffers builderfloat[][]
toFloatMatrix()
Convert this ndarray to a 2d float matrix.float[]
toFloatVector()
Convert this ndarray to a 1d float vector.int[][]
toIntMatrix()
Convert this ndarray to a 2d int matrix.int[]
toIntVector()
Convert this ndarray to a 1d int matrix.long[][]
toLongMatrix()
Convert this ndarray to a 2d int matrix.long[]
toLongVector()
Convert this ndarray to a 1d long matrix.String
toString(long maxElements, boolean forceSummarize, int precision)
Get a string representation of the arrayString
toString(@NonNull NDArrayStrings options)
Get a string representation of the array with configurable formattingString
toStringFull()
ToString with unlimited elements and precisionINDArray
transpose()
Flip the rows and columns of a matrixINDArray
transposei()
Flip the rows and columns of a matrix, in-placeINDArray
ulike()
This method returns uninitialized array with the same dtype/order/shape as this oneINDArray
unsafeDuplication()
Perform efficient (but unsafe) duplication.INDArray
unsafeDuplication(boolean blocking)
Perform efficient (but unsafe) duplication.INDArray
var(boolean biasCorrected, int... dimension)
Returns the overall variance of this ndarrayINDArray
var(int... dimension)
Returns the overall variance of this ndarrayNumber
varNumber()
Returns the overall variance of all values in this INDArrayINDArray
vectorAlongDimension(int index, int dimension)
Get the vector along a particular dimensionlong
vectorsAlongDimension(int dimension)
Returns the number of possible vectors for a given dimensionboolean
wasClosed()
This method checks if array or its buffer was closed before
-
-
-
Method Detail
-
shapeInfoToString
String shapeInfoToString()
Returns the shape information debugging information- Returns:
- the shape information.
-
shapeInfoDataBuffer
DataBuffer shapeInfoDataBuffer()
Shape info- Returns:
- Shape info
-
shapeInfo
LongBuffer shapeInfo()
Shape info- Returns:
- Shape info
-
isView
boolean isView()
Check if this array is a view or not.- Returns:
- true if array is a view.
-
isSparse
boolean isSparse()
Check if this array is sparse- Returns:
- true if this array is sparse.
-
isCompressed
boolean isCompressed()
Check if this array is compressed.- Returns:
- true if this array is compressed.
-
markAsCompressed
void markAsCompressed(boolean reallyCompressed)
This method marks INDArray instance as compressed PLEASE NOTE: Do not use this method unless you 100% have to- Parameters:
reallyCompressed
- new value for compressed.
-
rank
int rank()
Returns the rank of the ndarray (the number of dimensions).- Returns:
- the rank for the ndarray.
-
stride
int stride(int dimension)
Calculate the stride along a particular dimension- Parameters:
dimension
- the dimension to get the stride for- Returns:
- the stride for a particular dimension
-
elementWiseStride
int elementWiseStride()
Element wise stride- Returns:
- the element wise stride
-
getDoubleUnsafe
double getDoubleUnsafe(long offset)
Get a double at the given linear offset unsafe, without checks.- Parameters:
offset
- the offset to get at- Returns:
- double value at offset
-
getString
String getString(long index)
Get string value at given index.- Parameters:
index
- index to retreive- Returns:
- string value at index.
-
putScalarUnsafe
INDArray putScalarUnsafe(long offset, double value)
Insert a scalar at the given linear offset- Parameters:
offset
- the offset to insert atvalue
- the value to insert- Returns:
- this
-
vectorsAlongDimension
long vectorsAlongDimension(int dimension)
Returns the number of possible vectors for a given dimension- Parameters:
dimension
- the dimension to calculate the number of vectors for- Returns:
- the number of possible vectors along a dimension
-
vectorAlongDimension
INDArray vectorAlongDimension(int index, int dimension)
Get the vector along a particular dimension- Parameters:
index
- the index of the vector to getScalardimension
- the dimension to getScalar the vector from- Returns:
- the vector along a particular dimension
-
tensorsAlongDimension
long tensorsAlongDimension(int... dimension)
Returns the number of possible vectors for a given dimension- Parameters:
dimension
- the dimension to calculate the number of vectors for- Returns:
- the number of possible vectors along a dimension
-
tensorAlongDimension
INDArray tensorAlongDimension(long index, int... dimension)
Get the vector along a particular dimension- Parameters:
index
- the index of the vector to getScalardimension
- the dimension to getScalar the vector from- Returns:
- the vector along a particular dimension
-
cumsumi
INDArray cumsumi(int dimension)
Returns the cumulative sum along a dimension. In-place method.- Parameters:
dimension
- the dimension to perform cumulative sum along.- Returns:
- this object.
-
cumsum
INDArray cumsum(int dimension)
Returns the cumulative sum along a dimension.- Parameters:
dimension
- the dimension to perform cumulative sum along.- Returns:
- the cumulative sum along the specified dimension
-
assign
INDArray assign(INDArray arr)
Assign all of the elements in the given ndarray to this ndarray- Parameters:
arr
- the elements to assign- Returns:
- this
-
assignIf
INDArray assignIf(INDArray arr, Condition condition)
Assign all elements from given ndarray that are matching given condition, ndarray to this ndarray- Parameters:
arr
- the elements to assign- Returns:
- this
-
replaceWhere
INDArray replaceWhere(INDArray arr, Condition condition)
Replaces all elements in this ndarray that are matching give condition, with corresponding elements from given array- Parameters:
arr
- Source arraycondition
- Condition to apply- Returns:
- New array with values conditionally replaced
-
putScalar
INDArray putScalar(long i, double value)
Insert the number linearly in to the ndarray- Parameters:
i
- the index to insert intovalue
- the value to insert- Returns:
- this
-
putScalar
INDArray putScalar(long i, float value)
Insert a scalar float at the specified index- Parameters:
i
- The index to insert intovalue
- Value to insert- Returns:
- This array
-
putScalar
INDArray putScalar(long i, int value)
Insert a scalar int at the specified index- Parameters:
i
- The index to insert intovalue
- Value to insert- Returns:
- This array
-
putScalar
INDArray putScalar(int[] i, double value)
Insert the item at the specified indices- Parameters:
i
- the indices to insert atvalue
- the number to insert- Returns:
- this
-
putScalar
INDArray putScalar(long[] i, double value)
-
putScalar
INDArray putScalar(long[] i, float value)
-
putScalar
INDArray putScalar(long[] i, int value)
-
putScalar
INDArray putScalar(long row, long col, double value)
Insert the value at the specified indices, in a 2d (rank 2) NDArray
Equivalent toputScalar(int[], double)
but avoids int[] creation- Parameters:
row
- Row (dimension 0) indexcol
- Column (dimension 1) indexvalue
- Value to put- Returns:
- This INDArray
-
putScalar
INDArray putScalar(long dim0, long dim1, long dim2, double value)
Insert the value at the specified indices, in a 3d (rank 3) NDArray
Equivalent toputScalar(int[], double)
but avoids int[] creation- Parameters:
dim0
- Dimension 0 indexdim1
- Dimension 1 indexdim2
- Dimension 2 indexvalue
- Value to put- Returns:
- This INDArray
-
putScalar
INDArray putScalar(long dim0, long dim1, long dim2, long dim3, double value)
Insert the value at the specified indices, in a 4d (rank 4) NDArray
Equivalent toputScalar(int[], double)
but avoids int[] creation- Parameters:
dim0
- Dimension 0 indexdim1
- Dimension 1 indexdim2
- Dimension 2 indexdim3
- Dimension 3 indexvalue
- Value to put- Returns:
- This INDArray
-
lt
INDArray lt(Number other)
Returns the binary ndarray for "Less" comparison.- Parameters:
other
- the number to compare.- Returns:
- the binary ndarray for "Less" comparison.
-
putScalar
INDArray putScalar(int[] indexes, float value)
Put the specified float value at the specified indices in this array- Parameters:
indexes
- Indices to place the valuevalue
- Value to insert- Returns:
- This array
-
putScalar
INDArray putScalar(int[] indexes, int value)
Put the specified integer value at the specified indices in this array- Parameters:
indexes
- Indices to place the valuevalue
- Value to insert- Returns:
- This array
-
eps
INDArray eps(Number other)
Returns the binary ndarray for "Epsilon equals" comparison.- Parameters:
other
- the number to compare.- Returns:
- the binary ndarray for "Epsilon equals" comparison.
-
eq
INDArray eq(Number other)
Returns the binary ndarray for "Equals" comparison.- Parameters:
other
- the number to compare.- Returns:
- the binary ndarray for "Equals" comparison.
-
gt
INDArray gt(Number other)
Returns the binary ndarray for "Greater" comparison.- Parameters:
other
- the number to compare.- Returns:
- the binary ndarray for "Greater" comparison.
-
gte
INDArray gte(Number other)
Returns binary ndarray for "Greter or equals" comparison.- Parameters:
other
- the number to compare.- Returns:
- binary ndarray for "Greter or equals" comparison.
-
lte
INDArray lte(Number other)
Returns the binary ndarray for "Less or equals" comparison.- Parameters:
other
- the number to compare.- Returns:
- the binary ndarray for "Less or equals" comparison.
-
lt
INDArray lt(INDArray other)
Returns the binary ndarray for "Less" comparison.- Parameters:
other
- the ndarray to compare.- Returns:
- the binary ndarray for "Less" comparison.
-
eps
INDArray eps(INDArray other)
Returns the binary ndarray for "Epsilon equals" comparison.- Parameters:
other
- the ndarray to compare.- Returns:
- the binary ndarray for "Epsilon equals" comparison.
-
neq
INDArray neq(Number other)
Returns the binary ndarray for "Not equals" comparison.- Parameters:
other
- the number to compare.- Returns:
- the binary ndarray for "Not equals" comparison.
-
neq
INDArray neq(INDArray other)
Returns the binary ndarray for "Not equals" comparison.- Parameters:
other
- the ndarray to compare.- Returns:
- the binary ndarray for "Not equals" comparison.
-
eq
INDArray eq(INDArray other)
Returns the binary ndarray for "Equals" comparison.- Parameters:
other
- the ndarray to compare.- Returns:
- the binary ndarray for "Equals" comparison.
-
gt
INDArray gt(INDArray other)
Returns the binary ndarray for "Greater Than" comparison.- Parameters:
other
- the ndarray to compare.- Returns:
- the binary ndarray for "Greater Than" comparison.
-
isInfinite
INDArray isInfinite()
Returns the binary NDArray with value true where this array's entries are infinite, or false where they are not infinite
-
isNaN
INDArray isNaN()
Returns the binary NDArray with value true where this array's entries are NaN, or false where they are not infinite
-
neg
INDArray neg()
Returns the ndarray negative (cloned)- Returns:
- Array copy with all values negated
-
negi
INDArray negi()
In place setting of the negative version of this ndarray- Returns:
- This array with all values negated
-
rdiv
INDArray rdiv(Number n)
Reverse division with a scalar - i.e., (n / thisArrayValues)- Parameters:
n
- Value to use for reverse division- Returns:
- Copy of array after applying reverse division
-
rdivi
INDArray rdivi(Number n)
In place reverse division - i.e., (n / thisArrayValues)- Parameters:
n
- Value to use for reverse division- Returns:
- This array after applying reverse division
-
rsub
INDArray rsub(Number n)
Reverse subtraction with duplicates - i.e., (n - thisArrayValues)- Parameters:
n
- Value to use for reverse subtraction- Returns:
- Copy of array after reverse subtraction
-
rsubi
INDArray rsubi(Number n)
Reverse subtraction in place - i.e., (n - thisArrayValues)- Parameters:
n
- Value to use for reverse subtraction- Returns:
- This array after reverse subtraction
-
div
INDArray div(Number n)
Division by a number- Parameters:
n
- Number to divide values by- Returns:
- Copy of array after division
-
divi
INDArray divi(Number n)
In place scalar division- Parameters:
n
- Number to divide values by- Returns:
- This array, after applying division operation
-
mul
INDArray mul(Number n)
Scalar multiplication (copy)- Parameters:
n
- the number to multiply by- Returns:
- a copy of this ndarray multiplied by the given number
-
muli
INDArray muli(Number n)
In place scalar multiplication- Parameters:
n
- The number to multiply by- Returns:
- This array, after applying scaler multiplication
-
sub
INDArray sub(Number n)
Scalar subtraction (copied)- Parameters:
n
- the number to subtract by- Returns:
- Copy of this array after applying subtraction operation
-
subi
INDArray subi(Number n)
In place scalar subtraction- Parameters:
n
- Number to subtract- Returns:
- This array, after applying subtraction operation
-
add
INDArray add(Number n)
Scalar addition (cloning)- Parameters:
n
- the number to add- Returns:
- a clone with this matrix + the given number
-
addi
INDArray addi(Number n)
In place scalar addition- Parameters:
n
- Number to add- Returns:
- This array, after adding value
-
rdiv
INDArray rdiv(Number n, INDArray result)
Reverse division (number / ndarray)- Parameters:
n
- the number to divide byresult
- Array to place the result in. Must match shape of this array- Returns:
- Result array
-
rdivi
INDArray rdivi(Number n, INDArray result)
Reverse in place division- Parameters:
n
- the number to divide byresult
- the result ndarray- Returns:
- the result ndarray
-
rsub
INDArray rsub(Number n, INDArray result)
Reverse subtraction- Parameters:
n
- the number to subtract byresult
- the result ndarray- Returns:
- the result ndarray
-
rsubi
INDArray rsubi(Number n, INDArray result)
Reverse in place subtraction- Parameters:
n
- the number to subtract byresult
- the result ndarray- Returns:
- the result ndarray
-
div
INDArray div(Number n, INDArray result)
Division if ndarray by number- Parameters:
n
- the number to divide byresult
- the result ndarray- Returns:
- the result ndarray
-
divi
INDArray divi(Number n, INDArray result)
In place division of this ndarray- Parameters:
n
- the number to divide byresult
- the result ndarray- Returns:
- the result ndarray
-
mul
INDArray mul(Number n, INDArray result)
Multiplication of ndarray.- Parameters:
n
- the number to multiply byresult
- the result ndarray- Returns:
- the result ndarray
-
muli
INDArray muli(Number n, INDArray result)
In place multiplication of this ndarray- Parameters:
n
- the number to divide byresult
- the result ndarray- Returns:
- the result ndarray
-
sub
INDArray sub(Number n, INDArray result)
Subtraction of this ndarray- Parameters:
n
- the number to subtract byresult
- the result ndarray- Returns:
- the result ndarray
-
subi
INDArray subi(Number n, INDArray result)
In place subtraction of this ndarray- Parameters:
n
- the number to subtract byresult
- the result ndarray- Returns:
- the result ndarray
-
add
INDArray add(Number n, INDArray result)
Addition of this ndarray.- Parameters:
n
- the number to addresult
- the result ndarray- Returns:
- the result ndarray
-
addi
INDArray addi(Number n, INDArray result)
In place addition- Parameters:
n
- the number to addresult
- the result ndarray- Returns:
- the result ndarray
-
get
INDArray get(INDArrayIndex... indexes)
Returns a subset of this array based on the specified indexes- Parameters:
indexes
- the indexes in to the array- Returns:
- a view of the array with the specified indices
-
match
INDArray match(INDArray comp, Condition condition)
Return a mask on whether each element matches the given condition- Parameters:
comp
-condition
-- Returns:
-
match
INDArray match(Number comp, Condition condition)
Returns a mask- Parameters:
comp
-condition
-- Returns:
-
getWhere
INDArray getWhere(INDArray comp, Condition condition)
Boolean indexing: Return the element if it fulfills the condition in result array- Parameters:
comp
- the comparison arraycondition
- the condition to apply- Returns:
- the array fulfilling the criteria
-
getWhere
INDArray getWhere(Number comp, Condition condition)
Boolean indexing: Return the element if it fulfills the condition in result array- Parameters:
comp
- the comparison arraycondition
- the condition to apply- Returns:
- the array fulfilling the criteria
-
putWhere
INDArray putWhere(INDArray comp, INDArray put, Condition condition)
Assign the element according to the comparison array- Parameters:
comp
- the comparison arrayput
- the elements to putcondition
- the condition for masking on- Returns:
- a copy of this array with the conditional assignments.
-
putWhere
INDArray putWhere(Number comp, INDArray put, Condition condition)
Assign the element according to the comparison array- Parameters:
comp
- the comparison arrayput
- the elements to putcondition
- the condition for masking on- Returns:
- a copy of this array with the conditional assignments.
-
putWhereWithMask
INDArray putWhereWithMask(INDArray mask, INDArray put)
Use a pre computed mask for assigning arrays- Parameters:
mask
- the mask to useput
- the array to put- Returns:
- a copy of this array with the conditional assignments.
-
putWhereWithMask
INDArray putWhereWithMask(INDArray mask, Number put)
Use a pre computed mask for assigning arrays- Parameters:
mask
- the mask to useput
- the array to put- Returns:
- a copy of this array with the conditional assignments.
-
putWhere
INDArray putWhere(Number comp, Number put, Condition condition)
Assign the element according to the comparison array- Parameters:
comp
- the comparison arrayput
- the elements to putcondition
- the condition for masking on- Returns:
- a copy of this array with the conditional assignments.
-
get
INDArray get(INDArray indices)
Get the elements from this ndarray based on the specified indices- Parameters:
indices
- an ndaray of the indices to get the elements for- Returns:
- the elements to get the array for
-
getColumns
INDArray getColumns(int... columns)
Get an INDArray comprised of the specified columns only. Copy operation.- Parameters:
columns
- Columns to extract out of the current array- Returns:
- Array with only the specified columns
-
getRows
INDArray getRows(int... rows)
Get an INDArray comprised of the specified rows only. Copy operation- Parameters:
rows
- Rose to extract from this array- Returns:
- Array with only the specified rows
-
rdiv
INDArray rdiv(INDArray other)
Reverse division, elements wise. i.e., other / this- Parameters:
other
- the matrix to divide from- Returns:
- Copy of this array after performing element wise reverse division
-
rdivi
INDArray rdivi(INDArray other)
Reverse divsion (in place). i.e., other / this- Parameters:
other
- The matrix to divide from- Returns:
- This array after performing element wise reverse division
-
rdiv
INDArray rdiv(INDArray other, INDArray result)
Reverse division- Parameters:
other
- the matrix to divide fromresult
- the result ndarray- Returns:
- the result ndarray
-
rdivi
INDArray rdivi(INDArray other, INDArray result)
Reverse division (in-place)- Parameters:
other
- the matrix to divide fromresult
- the result ndarray- Returns:
- the ndarray with the operation applied
-
rsub
INDArray rsub(INDArray other, INDArray result)
Reverse subtraction- Parameters:
other
- the matrix to subtract fromresult
- the result ndarray- Returns:
- the result ndarray
-
rsub
INDArray rsub(INDArray other)
Element-wise reverse subtraction (copy op). i.e., other - this- Parameters:
other
- Other array to use in reverse subtraction- Returns:
- Copy of this array, after applying reverse subtraction
-
rsubi
INDArray rsubi(INDArray other)
Element-wise reverse subtraction (in the place op) - i.e., other - this- Parameters:
other
- Other way to use in reverse subtraction operation- Returns:
- This array, after applying reverse subtraction
-
rsubi
INDArray rsubi(INDArray other, INDArray result)
Reverse subtraction (in-place)- Parameters:
other
- the other ndarray to subtractresult
- the result ndarray- Returns:
- the ndarray with the operation applied
-
assign
INDArray assign(Number value)
Set all entries of the ndarray to the specified value- Parameters:
value
- the value to assign- Returns:
- the ndarray with the values
-
assign
INDArray assign(boolean value)
Set all entries of the ndarray to the specified value- Parameters:
value
- the value to assign- Returns:
- the ndarray with the values
-
linearIndex
long linearIndex(long i)
Get the linear index of the data in to the array- Parameters:
i
- the index to getScalar- Returns:
- the linear index in to the data
-
sliceVectors
void sliceVectors(List<INDArray> list)
Flattens the array for linear indexing in list.
-
putSlice
INDArray putSlice(int slice, INDArray put)
Assigns the given matrix (put) to the specified slice- Parameters:
slice
- the slice to assignput
- the slice to applyTransformToDestination- Returns:
- this for chainability
-
cond
INDArray cond(Condition condition)
Returns a binary INDArray with value 'true' if the element matches the specified condition and 'false' otherwise- Parameters:
condition
- Condition to apply- Returns:
- Copy of this array with values 0 (condition does not apply), or one (condition applies)
-
repmat
INDArray repmat(long... shape)
Replicate and tile array to fill out to the given shape See: https://github.com/numpy/numpy/blob/master/numpy/matlib.py#L310-L358- Parameters:
shape
- the new shape of this ndarray- Returns:
- the shape to fill out to
-
repmat
@Deprecated INDArray repmat(int... shape)
Deprecated.
-
repeat
INDArray repeat(int dimension, long... repeats)
Repeat elements along a specified dimension.- Parameters:
dimension
- the dimension to repeatrepeats
- the number of elements to repeat on each element- Returns:
- Repeated array
-
putRow
INDArray putRow(long row, INDArray toPut)
Insert a row in to this array Will throw an exception if this ndarray is not a matrix- Parameters:
row
- the row insert intotoPut
- the row to insert- Returns:
- this
-
putColumn
INDArray putColumn(int column, INDArray toPut)
Insert a column in to this array Will throw an exception if this ndarray is not a matrix- Parameters:
column
- the column to inserttoPut
- the array to put- Returns:
- this
-
getScalar
INDArray getScalar(long row, long column)
Returns the element at the specified row/column- Parameters:
row
- the row of the element to returncolumn
- the row of the element to return- Returns:
- a scalar indarray of the element at this index
-
getScalar
INDArray getScalar(long i)
Returns the element at the specified index- Parameters:
i
- the index of the element to return- Returns:
- a scalar ndarray of the element at this index
-
squaredDistance
double squaredDistance(INDArray other)
Returns the square of the Euclidean distance.
-
distance2
double distance2(INDArray other)
Returns the (euclidean) distance.
-
distance1
double distance1(INDArray other)
Returns the (1-norm) distance.
-
put
INDArray put(INDArray indices, INDArray element)
Put element in to the indices denoted by the indices ndarray. In numpy this is equivalent to: a[indices] = element- Parameters:
indices
- the indices to putelement
- the element array to put- Returns:
- this array
-
put
INDArray put(INDArrayIndex[] indices, INDArray element)
Put the elements of the ndarray in to the specified indices- Parameters:
indices
- the indices to put the ndarray in toelement
- the ndarray to put- Returns:
- this ndarray
-
put
INDArray put(INDArrayIndex[] indices, Number element)
Put the elements of the ndarray in to the specified indices- Parameters:
indices
- the indices to put the ndarray in toelement
- the ndarray to put- Returns:
- this ndarray
-
put
INDArray put(int[] indices, INDArray element)
Inserts the element at the specified index- Parameters:
indices
- the indices to insert intoelement
- a scalar ndarray- Returns:
- a scalar ndarray of the element at this index
-
put
INDArray put(int i, int j, INDArray element)
Inserts the element at the specified index- Parameters:
i
- the row insert intoj
- the column to insert intoelement
- a scalar ndarray- Returns:
- a scalar ndarray of the element at this index
-
put
INDArray put(int i, int j, Number element)
Inserts the element at the specified index- Parameters:
i
- the row insert intoj
- the column to insert intoelement
- a scalar ndarray- Returns:
- a scalar ndarray of the element at this index
-
put
INDArray put(int i, INDArray element)
Inserts the element at the specified index- Parameters:
i
- the index insert intoelement
- a scalar ndarray- Returns:
- a scalar ndarray of the element at this index
-
diviColumnVector
INDArray diviColumnVector(INDArray columnVector)
In place division of a column vector- Parameters:
columnVector
- the column vector used for division- Returns:
- the result of the division
-
divColumnVector
INDArray divColumnVector(INDArray columnVector)
Division of a column vector (copy)- Parameters:
columnVector
- the column vector used for division- Returns:
- the result of the division
-
diviRowVector
INDArray diviRowVector(INDArray rowVector)
In place division of a row vector- Parameters:
rowVector
- the row vector used for division- Returns:
- the result of the division
-
divRowVector
INDArray divRowVector(INDArray rowVector)
Division of a row vector (copy)- Parameters:
rowVector
- the row vector used for division- Returns:
- the result of the division
-
rdiviColumnVector
INDArray rdiviColumnVector(INDArray columnVector)
In place reverse divison of a column vector- Parameters:
columnVector
- the column vector used for division- Returns:
- the result of the division
-
rdivColumnVector
INDArray rdivColumnVector(INDArray columnVector)
Reverse division of a column vector (copy)- Parameters:
columnVector
- the column vector used for division- Returns:
- the result of the division
-
rdiviRowVector
INDArray rdiviRowVector(INDArray rowVector)
In place reverse division of a column vector- Parameters:
rowVector
- the row vector used for division- Returns:
- the result of the division
-
rdivRowVector
INDArray rdivRowVector(INDArray rowVector)
Reverse division of a column vector (copy)- Parameters:
rowVector
- the row vector used for division- Returns:
- the result of the division
-
muliColumnVector
INDArray muliColumnVector(INDArray columnVector)
In place multiplication of a column vector- Parameters:
columnVector
- the column vector used for multiplication- Returns:
- the result of the multiplication
-
mulColumnVector
INDArray mulColumnVector(INDArray columnVector)
Multiplication of a column vector (copy)- Parameters:
columnVector
- the column vector used for multiplication- Returns:
- the result of the multiplication
-
muliRowVector
INDArray muliRowVector(INDArray rowVector)
In place multiplication of a row vector- Parameters:
rowVector
- the row vector used for multiplication- Returns:
- the result of the multiplication
-
mulRowVector
INDArray mulRowVector(INDArray rowVector)
Multiplication of a row vector (copy)- Parameters:
rowVector
- the row vector used for multiplication- Returns:
- the result of the multiplication
-
rsubiColumnVector
INDArray rsubiColumnVector(INDArray columnVector)
In place reverse subtraction of a column vector- Parameters:
columnVector
- the column vector to subtract- Returns:
- the result of the subtraction
-
rsubColumnVector
INDArray rsubColumnVector(INDArray columnVector)
Reverse subtraction of a column vector (copy)- Parameters:
columnVector
- the column vector to subtract- Returns:
- the result of the subtraction
-
rsubiRowVector
INDArray rsubiRowVector(INDArray rowVector)
In place reverse subtraction of a row vector- Parameters:
rowVector
- the row vector to subtract- Returns:
- the result of the subtraction
-
rsubRowVector
INDArray rsubRowVector(INDArray rowVector)
Reverse subtraction of a row vector (copy)- Parameters:
rowVector
- the row vector to subtract- Returns:
- the result of the subtraction
-
subiColumnVector
INDArray subiColumnVector(INDArray columnVector)
In place subtraction of a column vector- Parameters:
columnVector
- the column vector to subtract- Returns:
- the result of the subtraction
-
subColumnVector
INDArray subColumnVector(INDArray columnVector)
Subtraction of a column vector (copy)- Parameters:
columnVector
- the column vector to subtract- Returns:
- the result of the subtraction
-
subiRowVector
INDArray subiRowVector(INDArray rowVector)
In place subtraction of a row vector- Parameters:
rowVector
- the row vector to subtract- Returns:
- the result of the subtraction
-
subRowVector
INDArray subRowVector(INDArray rowVector)
Subtraction of a row vector (copy)- Parameters:
rowVector
- the row vector to subtract- Returns:
- the result of the subtraction
-
addiColumnVector
INDArray addiColumnVector(INDArray columnVector)
In place addition of a column vector- Parameters:
columnVector
- the column vector to add- Returns:
- the result of the addition
-
putiColumnVector
INDArray putiColumnVector(INDArray columnVector)
In place assignment of a column vector- Parameters:
columnVector
- the column vector to add- Returns:
- the result of the addition
-
addColumnVector
INDArray addColumnVector(INDArray columnVector)
Addition of a column vector (copy)- Parameters:
columnVector
- the column vector to add- Returns:
- the result of the addition
-
addiRowVector
INDArray addiRowVector(INDArray rowVector)
In place addition of a row vector- Parameters:
rowVector
- the row vector to add- Returns:
- the result of the addition
-
putiRowVector
INDArray putiRowVector(INDArray rowVector)
in place assignment of row vector, to each row of this array- Parameters:
rowVector
- Row vector to put- Returns:
- This array, after assigning every road to the specified value
-
addRowVector
INDArray addRowVector(INDArray rowVector)
Addition of a row vector (copy)- Parameters:
rowVector
- the row vector to add- Returns:
- the result of the addition
-
mmul
INDArray mmul(INDArray other, MMulTranspose mMulTranspose)
Perform a copy matrix multiplication- Parameters:
other
- the other matrix to perform matrix multiply with- Returns:
- the result of the matrix multiplication
-
mmul
INDArray mmul(INDArray other)
Perform a copy matrix multiplication- Parameters:
other
- the other matrix to perform matrix multiply with- Returns:
- the result of the matrix multiplication
-
mmul
INDArray mmul(INDArray other, char resultOrder)
Perform a copy matrix multiplication- Parameters:
other
- other the other matrix to perform matrix multiply withresultOrder
- either C or F order for result array- Returns:
- the result of the matrix multiplication
-
toDoubleMatrix
double[][] toDoubleMatrix()
Convert this ndarray to a 2d double matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Returns:
- a copy of this array as a 2d double array
-
toDoubleVector
double[] toDoubleVector()
Convert this ndarray to a 1d double matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Returns:
- a copy of this array as a 1d double array
-
toFloatVector
float[] toFloatVector()
Convert this ndarray to a 1d float vector. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Returns:
- a copy of this array as a 1d float array
-
toFloatMatrix
float[][] toFloatMatrix()
Convert this ndarray to a 2d float matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Returns:
- a copy of this array as a 2d float array
-
toIntVector
int[] toIntVector()
Convert this ndarray to a 1d int matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Returns:
- a copy of this array as a 1d int array
-
toLongVector
long[] toLongVector()
Convert this ndarray to a 1d long matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Returns:
- a copy of this array as a 1d long array
-
toLongMatrix
long[][] toLongMatrix()
Convert this ndarray to a 2d int matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Returns:
- a copy of this array as a 2d int array
-
toIntMatrix
int[][] toIntMatrix()
Convert this ndarray to a 2d int matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Returns:
- a copy of this array as a 2d int array
-
mmul
INDArray mmul(INDArray other, INDArray result)
Perform an copy matrix multiplication- Parameters:
other
- the other matrix to perform matrix multiply withresult
- the result ndarray- Returns:
- the result of the matrix multiplication
-
mmul
INDArray mmul(INDArray other, INDArray result, MMulTranspose mMulTranspose)
Perform an copy matrix multiplication- Parameters:
other
- the other matrix to perform matrix multiply withresult
- the result ndarraymMulTranspose
- the transpose status of each array- Returns:
- the result of the matrix multiplication
-
div
INDArray div(INDArray other)
Copy (element wise) division of two NDArrays- Parameters:
other
- the second ndarray to divide- Returns:
- the result of the divide
-
div
INDArray div(INDArray other, INDArray result)
copy (element wise) division of two NDArrays- Parameters:
other
- the second ndarray to divideresult
- the result ndarray- Returns:
- the result of the divide
-
mul
INDArray mul(INDArray other)
copy (element wise) multiplication of two NDArrays- Parameters:
other
- the second ndarray to multiply- Returns:
- the result of the addition
-
mul
INDArray mul(INDArray other, INDArray result)
copy (element wise) multiplication of two NDArrays- Parameters:
other
- the second ndarray to multiplyresult
- the result ndarray- Returns:
- the result of the multiplication
-
sub
INDArray sub(INDArray other)
copy subtraction of two NDArrays- Parameters:
other
- the second ndarray to subtract- Returns:
- the result of the addition
-
sub
INDArray sub(INDArray other, INDArray result)
copy subtraction of two NDArrays- Parameters:
other
- the second ndarray to subtractresult
- the result ndarray- Returns:
- the result of the subtraction
-
add
INDArray add(INDArray other)
Element-wise copy addition of two NDArrays- Parameters:
other
- the second ndarray to add- Returns:
- the result of the addition
-
add
INDArray add(INDArray other, INDArray result)
Element-wise copy addition of two NDArrays- Parameters:
other
- the second ndarray to addresult
- the result ndarray- Returns:
- the result of the addition
-
mmuli
INDArray mmuli(INDArray other, MMulTranspose transpose)
Perform an copy matrix multiplication- Parameters:
other
- the other matrix to perform matrix multiply withtranspose
- the transpose status of each ndarray- Returns:
- the result of the matrix multiplication
-
mmuli
INDArray mmuli(INDArray other)
Perform an inplace matrix multiplication- Parameters:
other
- the other matrix to perform matrix multiply with- Returns:
- the result of the matrix multiplication
-
mmuli
INDArray mmuli(INDArray other, INDArray result, MMulTranspose transpose)
Perform an in place matrix multiplication- Parameters:
other
- the other matrix to perform matrix multiply withresult
- the result ndarray- Returns:
- the result of the matrix multiplication
-
mmuli
INDArray mmuli(INDArray other, INDArray result)
Perform an inplace matrix multiplication- Parameters:
other
- the other matrix to perform matrix multiply withresult
- the result ndarray- Returns:
- the result of the matrix multiplication
-
divi
INDArray divi(INDArray other)
in place (element wise) division of two NDArrays- Parameters:
other
- the second ndarray to divide- Returns:
- the result of the divide
-
divi
INDArray divi(INDArray other, INDArray result)
in place (element wise) division of two NDArrays- Parameters:
other
- the second ndarray to divideresult
- the result ndarray- Returns:
- the result of the divide
-
muli
INDArray muli(INDArray other)
in place (element wise) multiplication of two NDArrays- Parameters:
other
- the second ndarray to multiply- Returns:
- the result of the multiplication
-
muli
INDArray muli(INDArray other, INDArray result)
in place (element wise) multiplication of two NDArrays- Parameters:
other
- the second ndarray to multiplyresult
- the result ndarray- Returns:
- the result of the multiplication
-
subi
INDArray subi(INDArray other)
in place (element wise) subtraction of two NDArrays- Parameters:
other
- the second ndarray to subtract- Returns:
- the result of the subtraction
-
subi
INDArray subi(INDArray other, INDArray result)
in place (element wise) subtraction of two NDArrays- Parameters:
other
- the second ndarray to subtractresult
- the result ndarray- Returns:
- the result of the subtraction
-
addi
INDArray addi(INDArray other)
in place (element wise) addition of two NDArrays- Parameters:
other
- the second ndarray to add- Returns:
- the result of the addition
-
addi
INDArray addi(INDArray other, INDArray result)
in place (element wise) addition of two NDArrays- Parameters:
other
- the second ndarray to addresult
- the result ndarray- Returns:
- the result of the addition
-
normmax
INDArray normmax(int... dimension)
Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)- Parameters:
dimension
- the dimension to the max norm along- Returns:
- Max norm along the specified dimension
-
normmax
INDArray normmax(boolean keepDims, int... dimension)
Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)- Parameters:
dimension
- the dimension to the max norm alongkeepDims
- whether to keep reduced dimensions as dimensions of size 1- Returns:
- Max norm along the specified dimension
-
normmaxNumber
Number normmaxNumber()
Return the max norm (aka infinity norm, equal to the maximum absolute value) for the entire array- Returns:
- Max norm for the entire array
-
norm2
INDArray norm2(int... dimension)
Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)- Parameters:
dimension
- the dimension to getScalar the norm2 along- Returns:
- the norm2 along the specified dimension
-
norm2
INDArray norm2(boolean keepDims, int... dimension)
Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)- Parameters:
dimension
- the dimension to getScalar the norm2 alongkeepDims
- whether to keep reduced dimensions as dimensions of size 1- Returns:
- the norm2 along the specified dimension
-
norm2Number
Number norm2Number()
Return the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) for the entire array- Returns:
- L2 norm for the array
-
norm1
INDArray norm1(int... dimension)
Returns the norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) along the specified dimension- Parameters:
dimension
- the dimension to getScalar the norm1 along- Returns:
- the norm1 along the specified dimension
-
norm1
INDArray norm1(boolean keepDims, int... dimension)
Returns the norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) along the specified dimension- Parameters:
dimension
- the dimension to getScalar the norm1 alongkeepDims
- whether to keep reduced dimensions as dimensions of size 1- Returns:
- the norm1 along the specified dimension
-
norm1Number
Number norm1Number()
Calculate and return norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) for the entire array- Returns:
- Norm 1 for the array
-
std
INDArray std(int... dimension)
Standard deviation of an INDArray along one or more dimensions- Parameters:
dimension
- the dimension to getScalar the std along- Returns:
- the standard deviation along a particular dimension
-
stdNumber
Number stdNumber()
Calculate the standard deviation for the entire array- Returns:
- standard deviation
-
std
INDArray std(boolean biasCorrected, int... dimension)
Standard deviation of an ndarray along a dimension- Parameters:
dimension
- the dimension to getScalar the std along- Returns:
- the standard deviation along a particular dimension
-
std
INDArray std(boolean biasCorrected, boolean keepDims, int... dimension)
Standard deviation of an ndarray along a dimension- Parameters:
dimension
- the dimension to getScalar the std alongkeepDims
- whether to keep reduced dimensions as dimensions of size 1- Returns:
- the standard deviation along a particular dimension
-
stdNumber
Number stdNumber(boolean biasCorrected)
Calculate the standard deviation for the entire array, specifying whether it is bias corrected or not- Parameters:
biasCorrected
- If true: bias corrected standard deviation. False: not bias corrected- Returns:
- Standard dev
-
prod
INDArray prod(int... dimension)
Returns the product along a given dimension- Parameters:
dimension
- the dimension to getScalar the product along- Returns:
- the product along the specified dimension
-
prod
INDArray prod(boolean keepDims, int... dimension)
Returns the product along a given dimension- Parameters:
dimension
- the dimension to getScalar the product alongkeepDims
- whether to keep reduced dimensions as dimensions of size 1- Returns:
- the product along the specified dimension
-
prodNumber
Number prodNumber()
Calculate the product of all values in the array- Returns:
- Product of all values in the array
-
mean
INDArray mean(int... dimension)
Returns the overall mean of this ndarray- Parameters:
dimension
- the dimension to getScalar the mean along- Returns:
- the mean along the specified dimension of this ndarray
-
mean
INDArray mean(INDArray result, int... dimension)
Returns the overall mean of this ndarray- Parameters:
dimension
- the dimension to getScalar the mean along- Returns:
- the mean along the specified dimension of this ndarray
-
mean
INDArray mean(boolean keepDims, int... dimension)
Returns the overall mean of this ndarray- Parameters:
dimension
- the dimension to getScalar the mean alongkeepDims
- whether to keep reduced dimensions as dimensions of size 1- Returns:
- the mean along the specified dimension of this ndarray
-
mean
INDArray mean(INDArray result, boolean keepDims, int... dimension)
Returns the overall mean of this ndarray- Parameters:
dimension
- the dimension to getScalar the mean alongkeepDims
- whether to keep reduced dimensions as dimensions of size 1- Returns:
- the mean along the specified dimension of this ndarray
-
amean
INDArray amean(int... dimension)
Returns the absolute overall mean of this ndarray- Parameters:
dimension
- the dimension to getScalar the mean along- Returns:
- the absolute mean along the specified dimension of this ndarray
-
meanNumber
Number meanNumber()
Returns the overall mean of this ndarray- Returns:
- the mean along the specified dimension of this ndarray
-
ameanNumber
Number ameanNumber()
Returns the absolute overall mean of this ndarray- Returns:
- the mean along the specified dimension of this ndarray
-
var
INDArray var(int... dimension)
Returns the overall variance of this ndarray- Parameters:
dimension
- the dimension to getScalar the variance along- Returns:
- the variance along the specified dimension of this ndarray
-
var
INDArray var(boolean biasCorrected, int... dimension)
Returns the overall variance of this ndarray- Parameters:
biasCorrected
- boolean on whether to apply corrected biasdimension
- the dimension to getScalar the variance along- Returns:
- the variance along the specified dimension of this ndarray
-
varNumber
Number varNumber()
Returns the overall variance of all values in this INDArray- Returns:
- variance
-
max
INDArray max(int... dimension)
Returns the overall max of this ndarray along given dimensions- Parameters:
dimension
- the dimension to getScalar the max along- Returns:
- the max along the specified dimension of this ndarray
-
max
INDArray max(boolean keepDims, int... dimension)
Returns the overall max of this ndarray along given dimensions- Parameters:
dimension
- the dimension to getScalar the max alongkeepDims
- whether to keep reduced dimensions as dimensions of size 1- Returns:
- the max along the specified dimension of this ndarray
-
amax
INDArray amax(int... dimension)
Returns the absolute overall max of this ndarray along given dimensions- Parameters:
dimension
- the dimension to getScalar the amax along- Returns:
- the amax along the specified dimension of this ndarray
-
maxNumber
Number maxNumber()
Returns maximum value in this INDArray- Returns:
- maximum value
-
amaxNumber
Number amaxNumber()
Returns maximum (absolute) value in this INDArray- Returns:
- Max absolute value
-
min
INDArray min(int... dimension)
Returns the overall min of this ndarray- Parameters:
dimension
- the dimension to getScalar the min along- Returns:
- the min along the specified dimension of this ndarray
-
min
INDArray min(boolean keepDims, int... dimension)
Returns the overall min of this ndarray- Parameters:
dimension
- the dimension to getScalar the min alongkeepDims
- whether to keep reduced dimensions as dimensions of size 1- Returns:
- the min along the specified dimension of this ndarray
-
amin
INDArray amin(int... dimension)
Returns minimum (absolute) value in this INDArray, along the specified dimensions- Returns:
- Minimum absolute value
-
minNumber
Number minNumber()
Returns min value in this INDArray- Returns:
- Minimum value in the array
-
aminNumber
Number aminNumber()
Returns absolute min value in this INDArray- Returns:
- Absolute min value
-
sum
INDArray sum(int... dimension)
Returns the sum along the last dimension of this ndarray- Parameters:
dimension
- the dimension to getScalar the sum along- Returns:
- the sum along the specified dimension of this ndarray
-
sum
INDArray sum(boolean keepDims, int... dimension)
Returns the sum along the last dimension of this ndarray- Parameters:
dimension
- the dimension to getScalar the sum alongkeepDims
- whether to keep reduced dimensions as dimensions of size 1- Returns:
- the sum along the specified dimension of this ndarray
-
scan
Number scan(Condition condition)
This method takes boolean condition, and returns number of elements matching this condition- Parameters:
condition
- Condition to calculate matches for- Returns:
- Number of elements matching condition
-
sum
INDArray sum(INDArray result, int... dimension)
Returns the sum along the last dimension of this ndarray- Parameters:
result
- result of this operation will be stored heredimension
- the dimension to getScalar the sum along- Returns:
- the sum along the specified dimension of this ndarray
-
sum
INDArray sum(INDArray result, boolean keepDims, int... dimension)
Returns the sum along the last dimension of this ndarray- Parameters:
result
- result of this operation will be stored herekeepDims
- whether to keep reduced dimensions as dimensions of size 1dimension
- the dimension to getScalar the sum along- Returns:
- the sum along the specified dimension of this ndarray
-
sumNumber
Number sumNumber()
Sum the entire array- Returns:
- Sum of array
-
entropyNumber
Number entropyNumber()
Returns entropy value for this INDArray- Returns:
- entropy value
-
shannonEntropyNumber
Number shannonEntropyNumber()
Returns non-normalized Shannon entropy value for this INDArray- Returns:
- non-normalized Shannon entropy
-
logEntropyNumber
Number logEntropyNumber()
Returns log entropy value for this INDArray- Returns:
- log entropy value
-
entropy
INDArray entropy(int... dimension)
Returns entropy value for this INDArray along specified dimension(s)- Parameters:
dimension
- specified dimension(s)- Returns:
- entropy value
-
shannonEntropy
INDArray shannonEntropy(int... dimension)
Returns Shannon entropy value for this INDArray along specified dimension(s)- Parameters:
dimension
- specified dimension(s)- Returns:
- Shannon entropy
-
logEntropy
INDArray logEntropy(int... dimension)
Returns log entropy value for this INDArray along specified dimension(s)- Parameters:
dimension
- specified dimension(s)- Returns:
- log entropy value
-
setShapeAndStride
void setShapeAndStride(int[] shape, int[] stride)
Shape and stride setter- Parameters:
shape
- new value for shapestride
- new value for stride
-
setOrder
void setOrder(char order)
Set the ordering- Parameters:
order
- the ordering to set
-
getScalar
INDArray getScalar(int... indices)
Returns the elements at the specified indices- Parameters:
indices
- the indices to getScalar- Returns:
- the array with the specified elements
-
getScalar
INDArray getScalar(long... indices)
SeegetScalar(int[])
-
getInt
int getInt(int... indices)
Get an integer value at the specified indices. Result will be cast to an integer, precision loss is possible.- Parameters:
indices
- Indices to get the integer at. Number of indices must match the array rank.- Returns:
- Integer value at the specified index
-
getLong
long getLong(long index)
Get a long value at the specified index.- Parameters:
index
- Index to get the integer at.- Returns:
- long value at the specified index
-
getLong
long getLong(long... indices)
Get a long value at the specified indices.- Parameters:
indices
- Indices to get the double at. Number of indices must match the array rank.- Returns:
- long value at the specified index
-
getNumber
Number getNumber(long index)
Get the numeric value at the specified index.- Parameters:
index
- index to retreive.- Returns:
- numeric value at the specified index.
-
getNumber
Number getNumber(long... indices)
Get a numeric value at the specified indices.- Parameters:
indices
- Indices to get the value from. Number of indices must match the array rank.- Returns:
- Numeric value at the specified index
-
getDouble
double getDouble(int... indices)
Get a double value at the specified indices.- Parameters:
indices
- Indices to get the double at. Number of indices must match the array rank.- Returns:
- Double value at the specified index
-
getDouble
double getDouble(long... indices)
SeegetDouble(int[])
-
getFloat
float getFloat(int... indices)
Returns the elements at the specified indices- Parameters:
indices
- the indices to getScalar- Returns:
- the array with the specified elements
-
getFloat
float getFloat(long... indices)
SeegetFloat(int...)
-
getDouble
double getDouble(long i)
Get the double value at the specified linear index in the array- Parameters:
i
- Index- Returns:
- Double value at the specified index
-
getDouble
double getDouble(long i, long j)
Get the double value at the specified indices. Can only be used for 2D (rank 2) arrays.- Parameters:
i
- Dimension 0 (row) indexj
- Dimension 1 (column) index- Returns:
- double value at the specified indices
-
getFloat
float getFloat(long i)
Return the item at the linear index i- Parameters:
i
- the index of the item to getScalar- Returns:
- the item at index j
-
getFloat
float getFloat(long i, long j)
Return the item at row i column j Note that this is the same as calling getScalar(new int[]{i,j}- Parameters:
i
- the row to getScalarj
- the column to getScalar- Returns:
- the item at row i column j
-
dup
INDArray dup()
Returns a copy of this ndarray- Returns:
- a copy of this ndarray
-
dup
INDArray dup(char order)
Returns a copy of this ndarray, where the returned ndarray has the specified order- Parameters:
order
- order of the NDArray. 'f' or 'c'- Returns:
- copy of ndarray with specified order
-
ravel
INDArray ravel()
Returns a flattened version (row vector) of this ndarray- Returns:
- a flattened version (row vector) of this ndarray
-
ravel
INDArray ravel(char order)
Returns a flattened version (row vector) of this ndarray- Returns:
- a flattened version (row vector) of this ndarray
-
setData
void setData(DataBuffer data)
Set the data for this ndarray.- Parameters:
data
- new value for the ndarray data.
-
slices
long slices()
Returns the number of slices in this ndarray- Returns:
- the number of slices in this ndarray
-
getTrailingOnes
int getTrailingOnes()
Get the number of trailing ones in the array shape. For example, a rank 3 array with shape [10, 1, 1] would return 2 for this method- Returns:
- Number of trailing ones in shape
-
getLeadingOnes
int getLeadingOnes()
Get the number of leading ones in the array shape. For example, a rank 3 array with shape [1, 10, 1] would return value 1 for this method- Returns:
- Number of leading ones in shape
-
slice
INDArray slice(long i, int dimension)
Returns the slice of this from the specified dimension- Parameters:
i
- the index of the slice to returndimension
- the dimension of the slice to return- Returns:
- the slice of this matrix from the specified dimension and dimension
-
slice
INDArray slice(long i)
Returns the specified slice of this ndarray- Parameters:
i
- the index of the slice to return- Returns:
- the specified slice of this ndarray
-
offset
long offset()
Returns the start of where the ndarray is for the underlying data- Returns:
- the starting offset
-
originalOffset
long originalOffset()
Returns the start of where the ndarray is for the original data buffer- Returns:
- original offset.
-
reshape
INDArray reshape(char order, long... newShape)
Reshapes the ndarray (can't change the length of the ndarray). Typically this will be a view, unless reshaping without copying is impossible.- Parameters:
newShape
- the new shape of the ndarray- Returns:
- the reshaped ndarray
-
reshape
INDArray reshape(char order, int... newShape)
Reshapes the ndarray (can't change the length of the ndarray). Typically this will be a view, unless reshaping without copying is impossible.- Parameters:
newShape
- the new shape of the ndarray- Returns:
- the reshaped ndarray
-
reshape
INDArray reshape(char order, boolean enforceView, long... newShape)
Reshapes the ndarray (note: it's not possible to change the length of the ndarray). Typically this will be a view, unless reshaping without copying (i.e., returning a view) is impossible.
In that case, the behaviour will depend on the enforceView argument: enforceView == true: throw an exception
enforceView == false: return a copy- Parameters:
newShape
- the new shape of the ndarray- Returns:
- the reshaped ndarray
-
reshape
INDArray reshape(char order, int rows, int columns)
Reshapes the ndarray (can't change the length of the ndarray). Typically this will be a view, unless reshaping without copying is impossible.- Parameters:
rows
- the rows of the matrixcolumns
- the columns of the matrix- Returns:
- the reshaped ndarray
-
reshape
INDArray reshape(long... newShape)
Reshapes the ndarray (can't change the length of the ndarray). Typically this will be a view, unless reshaping without copying is impossible.- Parameters:
newShape
- the new shape of the ndarray- Returns:
- the reshaped ndarray
-
reshape
INDArray reshape(int[] shape)
Seereshape(long[])
-
reshape
INDArray reshape(long rows, long columns)
Reshapes the ndarray (can't change the length of the ndarray). Typically this will be a view, unless reshaping without copying is impossible.- Parameters:
rows
- the rows of the matrixcolumns
- the columns of the matrix- Returns:
- the reshaped ndarray
-
transpose
INDArray transpose()
Flip the rows and columns of a matrix- Returns:
- the flipped rows and columns of a matrix
-
transposei
INDArray transposei()
Flip the rows and columns of a matrix, in-place- Returns:
- the flipped rows and columns of a matrix
-
swapAxes
INDArray swapAxes(int dimension, int with)
Mainly here for people coming from numpy. This is equivalent to a call to permute- Parameters:
dimension
- the dimension to swapwith
- the one to swap it with- Returns:
- the swapped axes view
-
permute
INDArray permute(int... rearrange)
See: http://www.mathworks.com/help/matlab/ref/permute.html- Parameters:
rearrange
- the dimensions to swap to- Returns:
- the newly permuted array
-
permutei
INDArray permutei(int... rearrange)
An in-place version of permute. The array shape information (shape, strides) is modified by this operation (but not the data itself) See: http://www.mathworks.com/help/matlab/ref/permute.html- Parameters:
rearrange
- the dimensions to swap to- Returns:
- the current array
-
dimShuffle
INDArray dimShuffle(Object[] rearrange, int[] newOrder, boolean[] broadCastable)
Dimshuffle: an extension of permute that adds the ability to broadcast various dimensions. This will only accept integers and xs. An x indicates a dimension should be broadcasted rather than permuted. Examples originally from the theano docs: http://deeplearning.net/software/theano/library/tensor/basic.html Returns a view of this tensor with permuted dimensions. Typically the pattern will include the integers 0, 1, ... ndim-1, and any number of 'x' characters in dimensions where this tensor should be broadcasted. A few examples of patterns and their effect: ('x') -> make a 0d (scalar) into a 1d vector (0, 1) -> identity for 2d vectors (1, 0) -> inverts the first and second dimensions ('x', 0) -> make a row out of a 1d vector (N to 1xN) (0, 'x') -> make a column out of a 1d vector (N to Nx1) (2, 0, 1) -> AxBxC to CxAxB (0, 'x', 1) -> AxB to Ax1xB (1, 'x', 0) -> AxB to Bx1xA (1,) -> This remove dimensions 0. It must be a broadcastable dimension (1xA to A)- Parameters:
rearrange
- the dimensions to swap tonewOrder
- the new order (think permute)broadCastable
- (whether the dimension is broadcastable) (must be same length as new order)- Returns:
- the newly permuted array
-
getColumn
INDArray getColumn(long i)
Returns the specified column. Throws an exception if its not a matrix- Parameters:
i
- the column to getScalar- Returns:
- the specified column
-
getColumn
INDArray getColumn(long i, boolean keepDim)
Returns the specified column. Throws an exception if its not a matrix (rank 2). Returned array will either be 1D (keepDim = false) or 2D (keepDim = true) with shape [length, 1]- Parameters:
i
- the row to getkeepDim
- If true: return [length, 1] array. Otherwise: return [length] array- Returns:
- the specified row
-
getRow
INDArray getRow(long i)
Returns the specified row as a 1D vector. Throws an exception if its not a matrix- Parameters:
i
- the row to getScalar- Returns:
- the specified row
-
getRow
INDArray getRow(long i, boolean keepDim)
Returns the specified row. Throws an exception if its not a matrix. Returned array will either be 1D (keepDim = false) or 2D (keepDim = true) with shape [1, length]- Parameters:
i
- the row to getkeepDim
- If true: return [1,length] array. Otherwise: return [length] array- Returns:
- the specified row
-
columns
int columns()
Returns the number of columns in this matrix (throws exception if not 2d)- Returns:
- the number of columns in this matrix
-
rows
int rows()
Returns the number of rows in this matrix (throws exception if not 2d)- Returns:
- the number of rows in this matrix
-
isColumnVector
boolean isColumnVector()
Returns true if the number of columns is 1- Returns:
- true if the number of columns is 1
-
isRowVector
boolean isRowVector()
Returns true if the number of rows is 1- Returns:
- true if the number of rows is 1
-
isColumnVectorOrScalar
boolean isColumnVectorOrScalar()
Returns true if the number of columns is 1- Returns:
- true if the number of columns is 1
-
isRowVectorOrScalar
boolean isRowVectorOrScalar()
Returns true if the number of rows is 1- Returns:
- true if the number of rows is 1
-
isVector
boolean isVector()
Returns true if this ndarray is a vector- Returns:
- whether this ndarray is a vector
-
isVectorOrScalar
boolean isVectorOrScalar()
Returns true if this ndarray is a vector or scalar- Returns:
- whether this ndarray is a vector or scalar
-
isSquare
boolean isSquare()
Returns whether the matrix has the same rows and columns- Returns:
- true if the matrix has the same rows and columns false otherwise
-
isMatrix
boolean isMatrix()
Returns true if this ndarray is a matrix- Returns:
- whether this ndarray is a matrix
-
isScalar
boolean isScalar()
Returns true if this ndarray is a scalar- Returns:
- whether this ndarray is a scalar
-
shape
long[] shape()
Returns the shape of this ndarray- Returns:
- the shape of this ndarray
-
shapeDescriptor
LongShapeDescriptor shapeDescriptor()
Returns shape descriptor of this ndarray- Returns:
- shape descriptor
-
stride
long[] stride()
Returns the stride of this ndarray- Returns:
- the stride of this ndarray
-
ordering
char ordering()
Return the ordering (fortran or c 'f' and 'c' respectively) of this ndarray- Returns:
- the ordering of this ndarray
-
size
long size(int dimension)
Returns the size along a specified dimension- Parameters:
dimension
- the dimension to return the size for- Returns:
- the size of the array along the specified dimension
-
length
long length()
Returns the total number of elements in the ndarray- Returns:
- the number of elements in the ndarray
-
broadcast
INDArray broadcast(long... shape)
Broadcasts this ndarray to be the specified shape- Parameters:
shape
- the new shape of this ndarray- Returns:
- the broadcasted ndarray
-
broadcast
INDArray broadcast(INDArray result)
Broadcasts this ndarray to be the specified shape- Returns:
- the broadcasted ndarray
-
element
Object element()
Returns a scalar (individual element) of a scalar ndarray- Returns:
- the individual item in this ndarray
-
data
DataBuffer data()
Returns a linear double array representation of this ndarray- Returns:
- the linear double array representation of this ndarray
-
equalsWithEps
boolean equalsWithEps(Object o, double eps)
This method checks 2 INDArrays equality with given eps- Parameters:
o
- INDArray to compare against.eps
- Epsilon value to use for the quality operation- Returns:
- True if ndarrays are equal within eps.
-
equalShapes
boolean equalShapes(INDArray other)
This method checks 2 INDArrays for equal shapes.
Shapes are considered equal if:
(a) Both arrays have equal rank, and
(b) size(0)...size(rank()-1) are equal for both arrays- Parameters:
other
- Other- Returns:
- True if shap
-
unsafeDuplication
INDArray unsafeDuplication()
Perform efficient (but unsafe) duplication. Don't use this method unless you know exactly what you are doing. Instead, usedup()
- Returns:
- Unsafe duplicate of array
-
unsafeDuplication
INDArray unsafeDuplication(boolean blocking)
Perform efficient (but unsafe) duplication. Don't use this method unless you know exactly what you are doing. Instead, usedup()
- Returns:
- Unsafe duplicate of array
-
remainder
INDArray remainder(INDArray denominator)
Remainder operator- Parameters:
denominator
- the denominator- Returns:
- remainder
-
remainder
INDArray remainder(INDArray denominator, INDArray result)
Remainder operator- Parameters:
denominator
- the denominatorresult
- the result array to put this in- Returns:
- Remainder
-
remainder
INDArray remainder(Number denominator)
The scalar remainder- Parameters:
denominator
- the denominator as a scalar- Returns:
- Remainder
-
remainder
INDArray remainder(Number denominator, INDArray result)
The scalar remainder- Parameters:
denominator
- the denominator as a scalarresult
- the result array to put this in- Returns:
- Remainder
-
remainderi
INDArray remainderi(INDArray denominator)
In place remainder- Parameters:
denominator
- the denominator- Returns:
- Remainder
-
remainderi
INDArray remainderi(Number denominator)
In place remainder- Parameters:
denominator
- the denominator- Returns:
- Remainder
-
fmod
INDArray fmod(INDArray denominator)
remainder of division- Parameters:
denominator
- the array of denominators for each element in this array- Returns:
- array of remainders
-
fmod
INDArray fmod(INDArray denominator, INDArray result)
remainder of division- Parameters:
denominator
- the array of denominators for each element in this arrayresult
- the result array- Returns:
- array of remainders
-
fmod
INDArray fmod(Number denominator)
remainder of division by scalar.- Parameters:
denominator
- the denominator- Returns:
- array of remainders
-
fmod
INDArray fmod(Number denominator, INDArray result)
remainder of division by scalar.- Parameters:
denominator
- the denominatorresult
- the result array- Returns:
- array of remainders
-
fmodi
INDArray fmodi(INDArray denominator)
In place fmod- Parameters:
denominator
- the array of denominators for each element in this array- Returns:
- array of remainders
-
fmodi
INDArray fmodi(Number denominator)
In place fmod- Parameters:
denominator
- the denominator as a scalar- Returns:
- array of remainders
-
argMax
INDArray argMax(int... dimension)
This method returns index of highest value along specified dimension(s)- Parameters:
dimension
- Dimension along which to perform the argMax operation- Returns:
- Array containing indices
-
isAttached
boolean isAttached()
This method returns True, if this INDArray instance is attached to some Workspace. False otherwise.- Returns:
- True if attached to workspace, false otherwise
-
isInScope
boolean isInScope()
This method checks, if given attached INDArray is still in scope of its parent Workspace PLEASE NOTE: if this INDArray isn't attached to any Workspace, this method will return true- Returns:
- true if attached to workspace.
-
detach
INDArray detach()
This method detaches INDArray from Workspace, returning copy. Basically it's dup() into new memory chunk. PLEASE NOTE: If this INDArray instance is NOT attached - it will be returned unmodified.- Returns:
- The attached copy of array, or original if not in workspace
-
leverage
INDArray leverage()
This method detaches INDArray from current Workspace, and attaches it to Workspace above, if any. PLEASE NOTE: If this INDArray instance is NOT attached - it will be returned unmodified. PLEASE NOTE: If current Workspace is the top-tier one, effect will be equal to detach() call - detached copy will be returned- Returns:
- this ndarray or a detached copy.
-
leverageTo
INDArray leverageTo(String id)
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id - if a workspace with that ID exists. If no workspace with the specified ID exists, the current INDArray is returned unmodified.- See Also:
leverageTo(String, boolean)
-
leverageTo
INDArray leverageTo(String id, boolean enforceExistence) throws Nd4jNoSuchWorkspaceException
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id. If enforceExistence == true, and no workspace with the specified ID exists, then anNd4jNoSuchWorkspaceException
is thrown. Otherwise, if enforceExistance == false and no workspace with the specified ID exists, then the current INDArray is returned unmodified (same asleverage()
- Parameters:
id
- ID of the workspace to leverage toenforceExistence
- If true, and the specified workspace does not exist: anNd4jNoSuchWorkspaceException
will be thrown.- Returns:
- The INDArray, leveraged to the specified workspace
- Throws:
Nd4jNoSuchWorkspaceException
- See Also:
leverageTo(String)
-
leverageOrDetach
INDArray leverageOrDetach(String id)
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id, if a workspace with the given ID is open and active. If the workspace does not exist, or is not active, the array is detached from any workspaces.- Parameters:
id
- ID of the workspace to leverage to- Returns:
- The INDArray, leveraged to the specified workspace (if it exists and is active) otherwise the detached array
- See Also:
leverageTo(String)
-
migrate
INDArray migrate()
This method pulls this INDArray into current Workspace. PLEASE NOTE: If there's no current Workspace - INDArray returned as is- Returns:
- Migrated INDArray or this if no current workspace
- See Also:
migrate(boolean)
-
migrate
INDArray migrate(boolean detachOnNoWs)
This method pulls this INDArray into current Workspace, or optionally detaches if no workspace is present.
That is:
If current workspace is present/active, INDArray is migrated to it.
If no current workspace is present/active, one of two things occur: 1. If detachOnNoWs arg is true: if there is no current workspace, INDArray is detached 2. If detachOnNoWs arg is false: this INDArray is returned as-is (no-op) - equivalent tomigrate()
- Parameters:
detachOnNoWs
- If true: detach on no WS. If false and no workspace: return this.- Returns:
- Migrated INDArray
-
percentileNumber
Number percentileNumber(Number percentile)
This method returns percentile value for this INDArray- Parameters:
percentile
- target percentile in range of 0..100- Returns:
- percentile value
-
medianNumber
Number medianNumber()
This method returns median value for this INDArray- Returns:
- Median value for array
-
median
INDArray median(int... dimension)
This method returns median along given dimension(s)- Parameters:
dimension
- Dimension to calculate median- Returns:
- Median along specified dimensions
-
percentile
INDArray percentile(Number percentile, int... dimension)
This method returns percentile along given dimension(s)- Parameters:
percentile
- target percentile in range of 0..100dimension
- Dimension to calculate percentile for- Returns:
- array with percentiles
-
toFlatArray
int toFlatArray(com.google.flatbuffers.FlatBufferBuilder builder)
Add anINDArray
to flatbuffers builder- Parameters:
builder
- the builder to use- Returns:
- the offset to add
-
isEmpty
boolean isEmpty()
This method returns true if this INDArray is special case: no-value INDArray- Returns:
- True if empty.
-
shapeInfoJava
long[] shapeInfoJava()
This method returns shapeInformation as jvm long array- Returns:
- shapeInformation
-
dataType
DataType dataType()
This method returns dtype for this INDArray- Returns:
- Datattype
-
isR
boolean isR()
This method checks if this INDArray instance is one of Real types- Returns:
- true if data type is floating point, false otherwise
-
isZ
boolean isZ()
This method checks if this INDArray instance is one of integer types- Returns:
- true if integer type
-
isB
boolean isB()
This method checks if this INDArray instance has boolean type- Returns:
- true if boolean type.
-
isS
boolean isS()
This method checks if this INDArray instance has String type- Returns:
- true if string type.
-
castTo
INDArray castTo(DataType dataType)
This method cast elements of this INDArray to new data type- Parameters:
dataType
- new datatype.- Returns:
- this if datatype matches, otherwise a new array of specified datatype.
-
all
boolean all()
This method checks if all elements within this array are non-zero (or true, in case of boolean)- Returns:
- true if all non-zero.
-
any
boolean any()
This method checks if any of the elements within this array are non-zero (or true, in case of boolean)- Returns:
- true if any non-zero.
-
none
boolean none()
This method checks if any of the elements within this array are non-zero (or true, in case of boolean)- Returns:
- true if any non-zero
-
closeable
boolean closeable()
This method checks, if this INDArray instalce can use close() method- Returns:
- true if array can be released, false otherwise
-
setCloseable
void setCloseable(boolean closeable)
Mainly for overriding closeable in specific situations where a user does not want an ndarray closed.- Parameters:
closeable
-
-
close
void close()
This method releases exclusive off-heap resources uses by this INDArray instance. If INDArray relies on shared resources, exception will be thrown instead PLEASE NOTE: This method is NOT safe by any means- Specified by:
close
in interfaceAutoCloseable
-
wasClosed
boolean wasClosed()
This method checks if array or its buffer was closed before- Returns:
- true if was closed, false otherwise
-
like
INDArray like()
This method returns empty array with the same dtype/order/shape as this one- Returns:
- empty array with the same dtype/order/shape
-
ulike
INDArray ulike()
This method returns uninitialized array with the same dtype/order/shape as this one- Returns:
- uninitialized array with the same dtype/order/shape
-
toString
String toString(@NonNull @NonNull NDArrayStrings options)
Get a string representation of the array with configurable formatting- Parameters:
options
- format options
-
toString
String toString(long maxElements, boolean forceSummarize, int precision)
Get a string representation of the array- Parameters:
maxElements
- Summarize if more than maxElements in the arrayforceSummarize
- Force a summary instead of a full printprecision
- The number of decimals to print. Doesn't print trailing 0s if negative- Returns:
- string representation of the array
-
toStringFull
String toStringFull()
ToString with unlimited elements and precision- See Also:
BaseNDArray.toString(long, boolean, int)
-
getId
long getId()
A unique ID for the INDArray object instance. Does not account for views.- Returns:
- INDArray unique ID
-
-