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 INDArrayadd(Number n)Scalar addition (cloning)INDArrayadd(Number n, INDArray result)Addition of this ndarray.INDArrayadd(INDArray other)Element-wise copy addition of two NDArraysINDArrayadd(INDArray other, INDArray result)Element-wise copy addition of two NDArraysINDArrayaddColumnVector(INDArray columnVector)Addition of a column vector (copy)INDArrayaddi(Number n)In place scalar additionINDArrayaddi(Number n, INDArray result)In place additionINDArrayaddi(INDArray other)in place (element wise) addition of two NDArraysINDArrayaddi(INDArray other, INDArray result)in place (element wise) addition of two NDArraysINDArrayaddiColumnVector(INDArray columnVector)In place addition of a column vectorINDArrayaddiRowVector(INDArray rowVector)In place addition of a row vectorINDArrayaddRowVector(INDArray rowVector)Addition of a row vector (copy)booleanall()This method checks if all elements within this array are non-zero (or true, in case of boolean)INDArrayamax(int... dimension)Returns the absolute overall max of this ndarray along given dimensionsNumberamaxNumber()Returns maximum (absolute) value in this INDArrayINDArrayamean(int... dimension)Returns the absolute overall mean of this ndarrayNumberameanNumber()Returns the absolute overall mean of this ndarrayINDArrayamin(int... dimension)Returns minimum (absolute) value in this INDArray, along the specified dimensionsNumberaminNumber()Returns absolute min value in this INDArraybooleanany()This method checks if any of the elements within this array are non-zero (or true, in case of boolean)INDArrayargMax(int... dimension)This method returns index of highest value along specified dimension(s)INDArrayassign(boolean value)Set all entries of the ndarray to the specified valueINDArrayassign(Number value)Set all entries of the ndarray to the specified valueINDArrayassign(INDArray arr)Assign all of the elements in the given ndarray to this ndarrayINDArrayassignIf(INDArray arr, Condition condition)Assign all elements from given ndarray that are matching given condition, ndarray to this ndarrayINDArraybroadcast(long... shape)Broadcasts this ndarray to be the specified shapeINDArraybroadcast(INDArray result)Broadcasts this ndarray to be the specified shapeINDArraycastTo(DataType dataType)This method cast elements of this INDArray to new data typevoidclose()This method releases exclusive off-heap resources uses by this INDArray instance.booleancloseable()This method checks, if this INDArray instalce can use close() methodintcolumns()Returns the number of columns in this matrix (throws exception if not 2d)INDArraycond(Condition condition)Returns a binary INDArray with value 'true' if the element matches the specified condition and 'false' otherwiseINDArraycumsum(int dimension)Returns the cumulative sum along a dimension.INDArraycumsumi(int dimension)Returns the cumulative sum along a dimension.DataBufferdata()Returns a linear double array representation of this ndarrayDataTypedataType()This method returns dtype for this INDArrayINDArraydetach()This method detaches INDArray from Workspace, returning copy.INDArraydimShuffle(Object[] rearrange, int[] newOrder, boolean[] broadCastable)Dimshuffle: an extension of permute that adds the ability to broadcast various dimensions.INDArraydimShuffle(Object[] rearrange, long[] newOrder, boolean[] broadCastable)doubledistance1(INDArray other)Returns the (1-norm) distance.doubledistance2(INDArray other)Returns the (euclidean) distance.INDArraydiv(Number n)Division by a numberINDArraydiv(Number n, INDArray result)Division if ndarray by numberINDArraydiv(INDArray other)Copy (element wise) division of two NDArraysINDArraydiv(INDArray other, INDArray result)copy (element wise) division of two NDArraysINDArraydivColumnVector(INDArray columnVector)Division of a column vector (copy)INDArraydivi(Number n)In place scalar divisionINDArraydivi(Number n, INDArray result)In place division of this ndarrayINDArraydivi(INDArray other)in place (element wise) division of two NDArraysINDArraydivi(INDArray other, INDArray result)in place (element wise) division of two NDArraysINDArraydiviColumnVector(INDArray columnVector)In place division of a column vectorINDArraydiviRowVector(INDArray rowVector)In place division of a row vectorINDArraydivRowVector(INDArray rowVector)Division of a row vector (copy)INDArraydup()Returns a copy of this ndarrayINDArraydup(char order)Returns a copy of this ndarray, where the returned ndarray has the specified orderObjectelement()Returns a scalar (individual element) of a scalar ndarrayintelementWiseStride()Element wise strideINDArrayentropy(int... dimension)Returns entropy value for this INDArray along specified dimension(s)NumberentropyNumber()Returns entropy value for this INDArrayINDArrayeps(Number other)Returns the binary ndarray for "Epsilon equals" comparison.INDArrayeps(INDArray other)Returns the binary ndarray for "Epsilon equals" comparison.INDArrayeq(Number other)Returns the binary ndarray for "Equals" comparison.INDArrayeq(INDArray other)Returns the binary ndarray for "Equals" comparison.booleanequalShapes(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 arraysbooleanequalsWithEps(Object o, double eps)This method checks 2 INDArrays equality with given epsINDArrayfmod(Number denominator)remainder of division by scalar.INDArrayfmod(Number denominator, INDArray result)remainder of division by scalar.INDArrayfmod(INDArray denominator)remainder of divisionINDArrayfmod(INDArray denominator, INDArray result)remainder of divisionINDArrayfmodi(Number denominator)In place fmodINDArrayfmodi(INDArray denominator)In place fmodINDArrayget(INDArray indices)Get the elements from this ndarray based on the specified indicesINDArrayget(INDArrayIndex... indexes)Returns a subset of this array based on the specified indexesINDArraygetColumn(long i)Returns the specified column.INDArraygetColumn(long i, boolean keepDim)Returns the specified column.INDArraygetColumns(int... columns)Get an INDArray comprised of the specified columns only.doublegetDouble(int... indices)Get a double value at the specified indices.doublegetDouble(long i)Get the double value at the specified linear index in the arraydoublegetDouble(long... indices)SeegetDouble(int[])doublegetDouble(long i, long j)Get the double value at the specified indices.doublegetDoubleUnsafe(long offset)Get a double at the given linear offset unsafe, without checks.floatgetFloat(int... indices)Returns the elements at the specified indicesfloatgetFloat(long i)Return the item at the linear index ifloatgetFloat(long... indices)SeegetFloat(int...)floatgetFloat(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}longgetId()A unique ID for the INDArray object instance.intgetInt(int... indices)Get an integer value at the specified indices.intgetLeadingOnes()Get the number of leading ones in the array shape.longgetLong(long index)Get a long value at the specified index.longgetLong(long... indices)Get a long value at the specified indices.NumbergetNumber(long index)Get the numeric value at the specified index.NumbergetNumber(long... indices)Get a numeric value at the specified indices.INDArraygetRow(long i)Returns the specified row as a 1D vector.INDArraygetRow(long i, boolean keepDim)Returns the specified row.INDArraygetRows(int... rows)Get an INDArray comprised of the specified rows only.INDArraygetScalar(int... indices)Returns the elements at the specified indicesINDArraygetScalar(long i)Returns the element at the specified indexINDArraygetScalar(long... indices)SeegetScalar(int[])INDArraygetScalar(long row, long column)Returns the element at the specified row/columnStringgetString(long index)Get string value at given index.intgetTrailingOnes()Get the number of trailing ones in the array shape.INDArraygetWhere(Number comp, Condition condition)Boolean indexing: Return the element if it fulfills the condition in result arrayINDArraygetWhere(INDArray comp, Condition condition)Boolean indexing: Return the element if it fulfills the condition in result arrayINDArraygt(Number other)Returns the binary ndarray for "Greater" comparison.INDArraygt(INDArray other)Returns the binary ndarray for "Greater Than" comparison.INDArraygte(Number other)Returns binary ndarray for "Greter or equals" comparison.booleanisAttached()This method returns True, if this INDArray instance is attached to some Workspace.booleanisB()This method checks if this INDArray instance has boolean typebooleanisColumnVector()Returns true if the number of columns is 1booleanisColumnVectorOrScalar()Returns true if the number of columns is 1booleanisCompressed()Check if this array is compressed.booleanisEmpty()This method returns true if this INDArray is special case: no-value INDArrayINDArrayisInfinite()Returns the binary NDArray with value true where this array's entries are infinite, or false where they are not infinitebooleanisInScope()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 truebooleanisMatrix()Returns true if this ndarray is a matrixINDArrayisNaN()Returns the binary NDArray with value true where this array's entries are NaN, or false where they are not infinitebooleanisR()This method checks if this INDArray instance is one of Real typesbooleanisRowVector()Returns true if the number of rows is 1booleanisRowVectorOrScalar()Returns true if the number of rows is 1booleanisS()This method checks if this INDArray instance has String typebooleanisScalar()Returns true if this ndarray is a scalarbooleanisSparse()Check if this array is sparsebooleanisSquare()Returns whether the matrix has the same rows and columnsbooleanisVector()Returns true if this ndarray is a vectorbooleanisVectorOrScalar()Returns true if this ndarray is a vector or scalarbooleanisView()Check if this array is a view or not.booleanisZ()This method checks if this INDArray instance is one of integer typeslonglength()Returns the total number of elements in the ndarrayINDArrayleverage()This method detaches INDArray from current Workspace, and attaches it to Workspace above, if any.INDArrayleverageOrDetach(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.INDArrayleverageTo(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.INDArrayleverageTo(String id, boolean enforceExistence)This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id.INDArraylike()This method returns empty array with the same dtype/order/shape as this onelonglinearIndex(long i)Get the linear index of the data in to the arrayINDArraylogEntropy(int... dimension)Returns log entropy value for this INDArray along specified dimension(s)NumberlogEntropyNumber()Returns log entropy value for this INDArrayINDArraylt(Number other)Returns the binary ndarray for "Less" comparison.INDArraylt(INDArray other)Returns the binary ndarray for "Less" comparison.INDArraylte(Number other)Returns the binary ndarray for "Less or equals" comparison.voidmarkAsCompressed(boolean reallyCompressed)This method marks INDArray instance as compressed PLEASE NOTE: Do not use this method unless you 100% have toINDArraymatch(Number comp, Condition condition)Returns a maskINDArraymatch(INDArray comp, Condition condition)Return a mask on whether each element matches the given conditionINDArraymax(boolean keepDims, int... dimension)Returns the overall max of this ndarray along given dimensionsINDArraymax(int... dimension)Returns the overall max of this ndarray along given dimensionsNumbermaxNumber()Returns maximum value in this INDArrayINDArraymean(boolean keepDims, int... dimension)Returns the overall mean of this ndarrayINDArraymean(int... dimension)Returns the overall mean of this ndarrayINDArraymean(INDArray result, boolean keepDims, int... dimension)Returns the overall mean of this ndarrayINDArraymean(INDArray result, int... dimension)Returns the overall mean of this ndarrayNumbermeanNumber()Returns the overall mean of this ndarrayINDArraymedian(int... dimension)This method returns median along given dimension(s)NumbermedianNumber()This method returns median value for this INDArrayINDArraymigrate()This method pulls this INDArray into current Workspace.INDArraymigrate(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.INDArraymin(boolean keepDims, int... dimension)Returns the overall min of this ndarrayINDArraymin(int... dimension)Returns the overall min of this ndarrayNumberminNumber()Returns min value in this INDArrayINDArraymmul(INDArray other)Perform a copy matrix multiplicationINDArraymmul(INDArray other, char resultOrder)Perform a copy matrix multiplicationINDArraymmul(INDArray other, MMulTranspose mMulTranspose)Perform a copy matrix multiplicationINDArraymmul(INDArray other, INDArray result)Perform an copy matrix multiplicationINDArraymmul(INDArray other, INDArray result, MMulTranspose mMulTranspose)Perform an copy matrix multiplicationINDArraymmuli(INDArray other)Perform an inplace matrix multiplicationINDArraymmuli(INDArray other, MMulTranspose transpose)Perform an copy matrix multiplicationINDArraymmuli(INDArray other, INDArray result)Perform an inplace matrix multiplicationINDArraymmuli(INDArray other, INDArray result, MMulTranspose transpose)Perform an in place matrix multiplicationINDArraymul(Number n)Scalar multiplication (copy)INDArraymul(Number n, INDArray result)Multiplication of ndarray.INDArraymul(INDArray other)copy (element wise) multiplication of two NDArraysINDArraymul(INDArray other, INDArray result)copy (element wise) multiplication of two NDArraysINDArraymulColumnVector(INDArray columnVector)Multiplication of a column vector (copy)INDArraymuli(Number n)In place scalar multiplicationINDArraymuli(Number n, INDArray result)In place multiplication of this ndarrayINDArraymuli(INDArray other)in place (element wise) multiplication of two NDArraysINDArraymuli(INDArray other, INDArray result)in place (element wise) multiplication of two NDArraysINDArraymuliColumnVector(INDArray columnVector)In place multiplication of a column vectorINDArraymuliRowVector(INDArray rowVector)In place multiplication of a row vectorINDArraymulRowVector(INDArray rowVector)Multiplication of a row vector (copy)INDArrayneg()Returns the ndarray negative (cloned)INDArraynegi()In place setting of the negative version of this ndarrayINDArrayneq(Number other)Returns the binary ndarray for "Not equals" comparison.INDArrayneq(INDArray other)Returns the binary ndarray for "Not equals" comparison.booleannone()This method checks if any of the elements within this array are non-zero (or true, in case of boolean)INDArraynorm1(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 dimensionINDArraynorm1(int... dimension)Returns the norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) along the specified dimensionNumbernorm1Number()Calculate and return norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) for the entire arrayINDArraynorm2(boolean keepDims, int... dimension)Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)INDArraynorm2(int... dimension)Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)Numbernorm2Number()Return the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) for the entire arrayINDArraynormmax(boolean keepDims, int... dimension)Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)INDArraynormmax(int... dimension)Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)NumbernormmaxNumber()Return the max norm (aka infinity norm, equal to the maximum absolute value) for the entire arraylongoffset()Returns the start of where the ndarray is for the underlying datacharordering()Return the ordering (fortran or c 'f' and 'c' respectively) of this ndarraylongoriginalOffset()Returns the start of where the ndarray is for the original data bufferINDArraypercentile(Number percentile, int... dimension)This method returns percentile along given dimension(s)NumberpercentileNumber(Number percentile)This method returns percentile value for this INDArrayINDArraypermute(int... rearrange)See: http://www.mathworks.com/help/matlab/ref/permute.htmlINDArraypermutei(int... rearrange)An in-place version of permute.INDArrayprod(boolean keepDims, int... dimension)Returns the product along a given dimensionINDArrayprod(int... dimension)Returns the product along a given dimensionNumberprodNumber()Calculate the product of all values in the arrayINDArrayput(int[] indices, INDArray element)Inserts the element at the specified indexINDArrayput(int i, int j, Number element)Inserts the element at the specified indexINDArrayput(int i, int j, INDArray element)Inserts the element at the specified indexINDArrayput(int i, INDArray element)Inserts the element at the specified indexINDArrayput(INDArray indices, INDArray element)Put element in to the indices denoted by the indices ndarray.INDArrayput(INDArrayIndex[] indices, Number element)Put the elements of the ndarray in to the specified indicesINDArrayput(INDArrayIndex[] indices, INDArray element)Put the elements of the ndarray in to the specified indicesINDArrayputColumn(int column, INDArray toPut)Insert a column in to this array Will throw an exception if this ndarray is not a matrixINDArrayputiColumnVector(INDArray columnVector)In place assignment of a column vectorINDArrayputiRowVector(INDArray rowVector)in place assignment of row vector, to each row of this arrayINDArrayputRow(long row, INDArray toPut)Insert a row in to this array Will throw an exception if this ndarray is not a matrixINDArrayputScalar(int[] i, double value)Insert the item at the specified indicesINDArrayputScalar(int[] indexes, float value)Put the specified float value at the specified indices in this arrayINDArrayputScalar(int[] indexes, int value)Put the specified integer value at the specified indices in this arrayINDArrayputScalar(long[] i, double value)INDArrayputScalar(long[] i, float value)INDArrayputScalar(long[] i, int value)INDArrayputScalar(long i, double value)Insert the number linearly in to the ndarrayINDArrayputScalar(long i, float value)Insert a scalar float at the specified indexINDArrayputScalar(long i, int value)Insert a scalar int at the specified indexINDArrayputScalar(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[] creationINDArrayputScalar(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[] creationINDArrayputScalar(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[] creationINDArrayputScalarUnsafe(long offset, double value)Insert a scalar at the given linear offsetINDArrayputSlice(int slice, INDArray put)Assigns the given matrix (put) to the specified sliceINDArrayputWhere(Number comp, Number put, Condition condition)Assign the element according to the comparison arrayINDArrayputWhere(Number comp, INDArray put, Condition condition)Assign the element according to the comparison arrayINDArrayputWhere(INDArray comp, INDArray put, Condition condition)Assign the element according to the comparison arrayINDArrayputWhereWithMask(INDArray mask, Number put)Use a pre computed mask for assigning arraysINDArrayputWhereWithMask(INDArray mask, INDArray put)Use a pre computed mask for assigning arraysintrank()Returns the rank of the ndarray (the number of dimensions).INDArrayravel()Returns a flattened version (row vector) of this ndarrayINDArrayravel(char order)Returns a flattened version (row vector) of this ndarrayINDArrayrdiv(Number n)Reverse division with a scalar - i.e., (n / thisArrayValues)INDArrayrdiv(Number n, INDArray result)Reverse division (number / ndarray)INDArrayrdiv(INDArray other)Reverse division, elements wise.INDArrayrdiv(INDArray other, INDArray result)Reverse divisionINDArrayrdivColumnVector(INDArray columnVector)Reverse division of a column vector (copy)INDArrayrdivi(Number n)In place reverse division - i.e., (n / thisArrayValues)INDArrayrdivi(Number n, INDArray result)Reverse in place divisionINDArrayrdivi(INDArray other)Reverse divsion (in place).INDArrayrdivi(INDArray other, INDArray result)Reverse division (in-place)INDArrayrdiviColumnVector(INDArray columnVector)In place reverse divison of a column vectorINDArrayrdiviRowVector(INDArray rowVector)In place reverse division of a column vectorINDArrayrdivRowVector(INDArray rowVector)Reverse division of a column vector (copy)INDArrayremainder(Number denominator)The scalar remainderINDArrayremainder(Number denominator, INDArray result)The scalar remainderINDArrayremainder(INDArray denominator)Remainder operatorINDArrayremainder(INDArray denominator, INDArray result)Remainder operatorINDArrayremainderi(Number denominator)In place remainderINDArrayremainderi(INDArray denominator)In place remainderINDArrayrepeat(int dimension, long... repeats)Repeat elements along a specified dimension.INDArrayreplaceWhere(INDArray arr, Condition condition)Replaces all elements in this ndarray that are matching give condition, with corresponding elements from given arrayINDArrayrepmat(int... shape)Deprecated.INDArrayrepmat(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-L358INDArrayreshape(char order, boolean enforceView, long... newShape)Reshapes the ndarray (note: it's not possible to change the length of the ndarray).INDArrayreshape(char order, int... newShape)Reshapes the ndarray (can't change the length of the ndarray).INDArrayreshape(char order, int rows, int columns)Reshapes the ndarray (can't change the length of the ndarray).INDArrayreshape(char order, long... newShape)Reshapes the ndarray (can't change the length of the ndarray).INDArrayreshape(int[] shape)Seereshape(long[])INDArrayreshape(long... newShape)Reshapes the ndarray (can't change the length of the ndarray).INDArrayreshape(long rows, long columns)Reshapes the ndarray (can't change the length of the ndarray).introws()Returns the number of rows in this matrix (throws exception if not 2d)INDArrayrsub(Number n)Reverse subtraction with duplicates - i.e., (n - thisArrayValues)INDArrayrsub(Number n, INDArray result)Reverse subtractionINDArrayrsub(INDArray other)Element-wise reverse subtraction (copy op).INDArrayrsub(INDArray other, INDArray result)Reverse subtractionINDArrayrsubColumnVector(INDArray columnVector)Reverse subtraction of a column vector (copy)INDArrayrsubi(Number n)Reverse subtraction in place - i.e., (n - thisArrayValues)INDArrayrsubi(Number n, INDArray result)Reverse in place subtractionINDArrayrsubi(INDArray other)Element-wise reverse subtraction (in the place op) - i.e., other - thisINDArrayrsubi(INDArray other, INDArray result)Reverse subtraction (in-place)INDArrayrsubiColumnVector(INDArray columnVector)In place reverse subtraction of a column vectorINDArrayrsubiRowVector(INDArray rowVector)In place reverse subtraction of a row vectorINDArrayrsubRowVector(INDArray rowVector)Reverse subtraction of a row vector (copy)Numberscan(Condition condition)This method takes boolean condition, and returns number of elements matching this conditionvoidsetCloseable(boolean closeable)Mainly for overriding closeable in specific situations where a user does not want an ndarray closed.voidsetData(DataBuffer data)Set the data for this ndarray.voidsetOrder(char order)Set the orderingvoidsetShapeAndStride(int[] shape, int[] stride)Shape and stride setterINDArrayshannonEntropy(int... dimension)Returns Shannon entropy value for this INDArray along specified dimension(s)NumbershannonEntropyNumber()Returns non-normalized Shannon entropy value for this INDArraylong[]shape()Returns the shape of this ndarrayLongShapeDescriptorshapeDescriptor()Returns shape descriptor of this ndarrayLongBuffershapeInfo()Shape infoDataBuffershapeInfoDataBuffer()Shape infolong[]shapeInfoJava()This method returns shapeInformation as jvm long arrayStringshapeInfoToString()Returns the shape information debugging informationlongsize(int dimension)Returns the size along a specified dimensionINDArrayslice(long i)Returns the specified slice of this ndarrayINDArrayslice(long i, int dimension)Returns the slice of this from the specified dimensionlongslices()Returns the number of slices in this ndarrayvoidsliceVectors(List<INDArray> list)Flattens the array for linear indexing in list.doublesquaredDistance(INDArray other)Returns the square of the Euclidean distance.INDArraystd(boolean biasCorrected, boolean keepDims, int... dimension)Standard deviation of an ndarray along a dimensionINDArraystd(boolean biasCorrected, int... dimension)Standard deviation of an ndarray along a dimensionINDArraystd(int... dimension)Standard deviation of an INDArray along one or more dimensionsNumberstdNumber()Calculate the standard deviation for the entire arrayNumberstdNumber(boolean biasCorrected)Calculate the standard deviation for the entire array, specifying whether it is bias corrected or notlong[]stride()Returns the stride of this ndarrayintstride(int dimension)Calculate the stride along a particular dimensionINDArraysub(Number n)Scalar subtraction (copied)INDArraysub(Number n, INDArray result)Subtraction of this ndarrayINDArraysub(INDArray other)copy subtraction of two NDArraysINDArraysub(INDArray other, INDArray result)copy subtraction of two NDArraysINDArraysubColumnVector(INDArray columnVector)Subtraction of a column vector (copy)INDArraysubi(Number n)In place scalar subtractionINDArraysubi(Number n, INDArray result)In place subtraction of this ndarrayINDArraysubi(INDArray other)in place (element wise) subtraction of two NDArraysINDArraysubi(INDArray other, INDArray result)in place (element wise) subtraction of two NDArraysINDArraysubiColumnVector(INDArray columnVector)In place subtraction of a column vectorINDArraysubiRowVector(INDArray rowVector)In place subtraction of a row vectorINDArraysubRowVector(INDArray rowVector)Subtraction of a row vector (copy)INDArraysum(boolean keepDims, int... dimension)Returns the sum along the last dimension of this ndarrayINDArraysum(int... dimension)Returns the sum along the last dimension of this ndarrayINDArraysum(INDArray result, boolean keepDims, int... dimension)Returns the sum along the last dimension of this ndarrayINDArraysum(INDArray result, int... dimension)Returns the sum along the last dimension of this ndarrayNumbersumNumber()Sum the entire arrayINDArrayswapAxes(int dimension, int with)Mainly here for people coming from numpy.INDArraytensorAlongDimension(long index, int... dimension)Get the vector along a particular dimensionlongtensorsAlongDimension(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.inttoFlatArray(com.google.flatbuffers.FlatBufferBuilder builder)Add anINDArrayto 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.StringtoString(long maxElements, boolean forceSummarize, int precision)Get a string representation of the arrayStringtoString(@NonNull NDArrayStrings options)Get a string representation of the array with configurable formattingStringtoStringFull()ToString with unlimited elements and precisionINDArraytranspose()Flip the rows and columns of a matrixINDArraytransposei()Flip the rows and columns of a matrix, in-placeINDArrayulike()This method returns uninitialized array with the same dtype/order/shape as this oneINDArrayunsafeDuplication()Perform efficient (but unsafe) duplication.INDArrayunsafeDuplication(boolean blocking)Perform efficient (but unsafe) duplication.INDArrayvar(boolean biasCorrected, int... dimension)Returns the overall variance of this ndarrayINDArrayvar(int... dimension)Returns the overall variance of this ndarrayNumbervarNumber()Returns the overall variance of all values in this INDArrayINDArrayvectorAlongDimension(int index, int dimension)Get the vector along a particular dimensionlongvectorsAlongDimension(int dimension)Returns the number of possible vectors for a given dimensionbooleanwasClosed()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 anNd4jNoSuchWorkspaceExceptionis 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: anNd4jNoSuchWorkspaceExceptionwill 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 anINDArrayto 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:
closein 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
-
-