Documentation of 'mikera.arrayz.INDArray' Java class
INDArray
mikera.arrayz

Interface INDArray

    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method and Description
      void abs()
      Replaces all elements of this array with their absolute values, according to Math.abs(double)
      INDArray absCopy()
      Returns a copy of the array with the abs operator applied to each element
      void absDiff(INDArray a)
      Sets this array to the absolute values of the difference between this array and another
      INDArray absDiffCopy(INDArray a)
      Returns an array containing the absolute values of the difference between this array and another
      void add(double a)
      Adds a double value to all elements in this array.
      void add(INDArray a)
      Adds all the elements of another array to this array, in an elementwise order.
      void addApplyOp(Op op, INDArray a)
      Adds the result of applying an Op to another array to this array.
      void addAt(long i, double v)
      Adds to a mutable array, indexed by element position in row major order.
      INDArray addCopy(double d)
      Creates a new array equal to this array with a constant value added to every element
      INDArray addCopy(INDArray a)
      Creates a new array equal to the sum of this array with another array.
      void addInnerProduct(INDArray a, INDArray b)
      Adds the inner product of two arrays to this array.
      void addInnerProduct(INDArray a, INDArray b, double d)
      Adds a scalar multiple of the inner product of two arrays to this array.
      void addMultiple(INDArray src, double factor)
      Adds a scaled multiple of another array to this array
      void addMultipleSparse(INDArray src, double factor)
      Adds a multiple of the source array to the non-sparse elements of this array
      void addOuterProduct(INDArray a, INDArray b)
      Adds the outer product of two arrays to this array.
      void addOuterProductSparse(INDArray a, INDArray b)
      Adds the outer product of two arrays to this array.
      void addPower(INDArray src, double exponent)
      Adds an array with all elements of the source array raised to the specified power
      void addPower(INDArray src, double exponent, double factor)
      Adds an array with all elements raised to the specified power and scaled by the given factor
      void addSparse(double c)
      Adds to the non-sparse elements of this array
      void addSparse(INDArray a)
      Adds the corresponding elements of the source array the non-sparse elements of this array
      void addToArray(double[] data, int offset)
      Adds all the elements of this array to a double array at the specified offset, in row-major order
      void applyOp(IOperator operator)
      Applies a unary operator to all elements of the array (in-place)
      void applyOp(Op op)
      Applies a unary operator to all elements of the array (in-place)
      void applyOp(Op2 op, double b)
      Applies a binary operator to this array and a double value.
      void applyOp(Op2 op, INDArray b)
      Applies a binary operator to this array and a second array.
      INDArray applyOpCopy(Op op)
      Applies a unary operator to all elements of the array (creating a new array)
      double[] asDoubleArray()
      Returns the underlying double array representing the densely packed elements of this array.
      java.util.List<java.lang.Double> asElementList()
      Returns a List containing all elements of this array
      AVector asVector()
      Constructs a view of all elements in the array as a single vector in row-major order.
      INDArray broadcast(int... shape)
      Returns a view of this array broadcasted up to a larger shape
      INDArray broadcastCloneLike(INDArray target)
      Creates a mutable clone of the array, broadcasted upwards if necessary to match the shape of the target.
      INDArray broadcastCopyLike(INDArray target)
      Creates a copy of the array, broadcasted upwards if necessary to match the shape of the target Like broadCastCloneLike, but does not guarantee a fully mutable clone - hence may be faster when used with immutable or specialized arrays
      AMatrix broadcastLike(AMatrix target)
      Broadcasts an array to match the shape of the target matrix
      AVector broadcastLike(AVector target)
      Broadcasts an array to match the shape of the target vector
      INDArray broadcastLike(INDArray target)
      Broadcasts an array to match the shape of the target
      void clamp(double min, double max)
      Clamps all the elements of this array within the specified [min,max] range
      INDArray clone()
      Returns a clone of the array data, as a new array which will be fully mutable and may be of a different class to the original.
      int componentCount()
      Returns the number of components of this array.
      INDArray copy()
      Returns a defensive copy of the array data.
      INDArray dense()
      Coerces this INDArray to a dense format, without changing its element values.
      INDArray denseClone()
      Creates a fully mutable dense clone of this array.
      int dimensionality()
      Returns the dimensionality of the array (i.e.
      void divide(double factor)
      Divides all elements by a given factor
      void divide(INDArray a)
      Divides all elements in place by the equivalent elements in a second array
      INDArray divideCopy(double d)
      Returns a copy of the array with all elements divided by a single constant value
      INDArray divideCopy(INDArray a)
      Divides all elements by the equivalent elements in a second array.
      double elementAbsPowSum(double p)
      Returns the sum of the absolute values of all the elements raised to a specified power
      long elementCount()
      Returns the total number of elements in this array.
      java.util.Iterator<java.lang.Double> elementIterator()
      Returns an iterator over all elements in this array, in row-major order
      double elementMax()
      Returns the maximum element value in this array.
      double elementMaxAbs()
      Returns the maximum absolute element value in this array.
      double elementMin()
      Returns the maximum element value in this array.
      double elementPowSum(double p)
      Returns the sum of all the elements raised to a specified power
      double elementProduct()
      Returns the product of all elements in the array.
      boolean elementsEqual(double value)
      Returns true if all elements are equal to a specific value
      double elementSquaredSum()
      Returns the sum of squared elements in this array.
      double elementSum()
      Returns the sum of all elements in this array.
      INDArray ensureMutable()
      Ensures the array is a fully mutable representation.
      boolean epsilonEquals(INDArray a)
      Tests if this array is approximately equal to another array.
      boolean epsilonEquals(INDArray a, double epsilon)
      Tests is this array is approximately equal to another array, up to a given tolerance (epsilon) The arrays must have the same shape
      boolean equals(INDArray a)
      Checks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTo
      boolean equalsArray(double[] data)
      Returns true if the elements in this array exactly match the elements in the given array, in row-major order.
      boolean equalsArray(double[] data, int offset)
      Returns true if the elements in this array exactly match the elements in the given array, in row-major order
      INDArray exactClone()
      Creates a deep clone of an array, using the same class implementation as the original array
      void exp()
      Computes the function e^x (in-place) for all array elements
      void fill(double value)
      Fills this array with a single double value.
      double get()
      Returns the double value of a scalar array
      double get(AIndex ix)
      Returns the double value at the specified position in the array
      double get(Index ix)
      Returns the double value at the specified position in the array
      double get(int... indexes)
      Returns the double value at the specified index position in an array
      double get(int x)
      Returns the double value at the specified position in a 1D vector
      double get(int x, int y)
      Returns the double value at the specified position in a 2D matrix
      double get(long x)
      Returns the double value at the specified position in a 1D vector
      double get(long[] indexes)
      Returns the double value at the specified index position in an array
      double get(long x, long y)
      Returns the double value at the specified position in a 2D matrix
      INDArray getComponent(int k)
      Gets a component from the array at the specified index Will throw an error if components are not supported, or if the component is out of bounds as defined by 0 <= k
      INDArray[] getComponents()
      Gets all components in a new array, with length componentCount();
      double getElement(long i)
      Gets a specific element of this array, indexed in row-major order
      double[] getElements()
      Gets all elements of the array as a Java double[] array
      void getElements(double[] arr)
      Copies all elements of this INDArray to the specified double array
      void getElements(double[] dest, int offset)
      Copies all elements of this array a double array at the specified offset
      void getElements(java.lang.Object[] dest, int offset)
      Copies all elements of this array into an object array at the specified offset
      long[] getLongShape()
      Returns the shape of the array as an array of longs.
      int[] getShape()
      Returns the shape of the array as an array of ints.
      int getShape(int dim)
      Returns the dimension size for a specific dimension in the array's shape
      int[] getShapeClone()
      Returns the shape of the array as an array of ints, guaranteed to be a new array i.e.
      java.util.List<?> getSlices()
      Returns a list of all major slices of this array.
      java.util.List<?> getSlices(int dimension)
      Returns a list of all slices of this array along a given dimension.
      java.util.List<INDArray> getSliceViews()
      Returns a list of slices as mutable INDArray views.
      INDArray getTranspose()
      Returns the transpose of this array.
      INDArray getTransposeCopy()
      Returns a transposed copy of the array.
      INDArray getTransposeView()
      Returns a transposed view of the array.
      boolean hasUncountable()
      Checks if the array has any uncountable element values (i.e.
      INDArray immutable()
      Returns an immutable version of this array.
      INDArray innerProduct(AScalar a)
      Calculates the inner product of this array with a scalar
      INDArray innerProduct(AVector v)
      Computes the inner product of this array with a vector
      INDArray innerProduct(double a)
      Calculates the inner product of this array with a double value
      INDArray innerProduct(INDArray a)
      Calculates the inner product of this array with another array.
      boolean isBoolean()
      Returns true if the array is boolean (contains only 0.0 or 1.0 values)
      boolean isDense()
      Returns true if the array is in a dense format.
      boolean isElementConstrained()
      Returns true if this array has some constraints on element values
      boolean isFullyMutable()
      If this method returns true, the INDArray is guaranteed to be fully mutable in all positions i.e.
      boolean isMutable()
      Returns true if the INDArray is mutable (at least partially)
      boolean isSameShape(INDArray a)
      Returns true if this array is the same shape as another array
      boolean isSparse()
      Returns true if the array is in a sparse format
      boolean isView()
      Return true if this array is considered as a view type.
      boolean isZero()
      Returns true if the array is zero (all elements equal to zero)
      INDArray join(INDArray a)
      Joins an array with another array along the major dimension Guarantees a view that combines the two joined arrays.
      INDArray join(INDArray a, int dimension)
      Joins an array with another array along a specified dimension.
      void log()
      Computes the natural logarithm (in-place) for all array elements
      void multiply(double factor)
      Multiplies all elements of the array in place by a given double value
      void multiply(INDArray a)
      Multiplies all elements by the equivalent elements in a second array, i.e.
      INDArray multiplyCopy(double factor)
      Returns a copy of the array with all elements multiplied by a single constant value
      INDArray multiplyCopy(INDArray a)
      Multiplies all elements by the equivalent elements in a second array, i.e.
      INDArray mutable()
      Coerces this INDArray to a fully mutable format.
      void negate()
      Negates all elements in the array in place
      INDArray negateCopy()
      Negates all elements in the array, returning a new array
      long nonZeroCount()
      Returns the number of non-zero elements in the array.
      INDArray outerProduct(INDArray a)
      Calculates the outer product of this array with another array.
      void pow(double exponent)
      Raises all elements of the array to a specified power in place
      void reciprocal()
      Replaces all elements in the array with their reciprocal
      INDArray reciprocalCopy()
      Returns a new array where every element is the reciprocal of the corresponding element in this array
      double reduce(Op2 op)
      Reduces over all elements of the array in row-major order.
      double reduce(Op2 op, double init)
      Reduces over all elements of the array in row-major order.
      AVector reduceSlices(Op2 op)
      Reduces each vector slice of the array by the given binary operator Reduces down to a single vector
      AVector reduceSlices(Op2 op, double init)
      Reduces each slice of the array by the given binary operator.
      INDArray reorder(int[] order)
      Returns a re-ordered array by taking the specified order of slices along dimension 0
      INDArray reorder(int dimension, int[] order)
      Returns a re-ordered array by taking the specified order of slices along a given dimension May or may not use views of underlying slices (i.e.
      INDArray reshape(int... shape)
      Returns a new array by rearranging the elements of this array into the desired shape Truncates or zero-pads the elements as required to fill the new shape
      INDArray rotateView(int dimension, int shift)
      Returns rotated view of this array
      void scale(double factor)
      Scales all elements of the array in place by a given double value
      void scaleAdd(double factor, double constant)
      Scales all elements of the array by a given double value and adds a constant value
      void scaleAdd(double factor, INDArray b, double bfactor, double constant)
      Scales all elements of the array by a given double value, adds a scaled second array and adds a constant value
      INDArray scaleCopy(double factor)
      Deprecated. 
      void set(double value)
      Sets all elements of an array to a specific double value
      void set(INDArray a)
      Sets this array to the element values contained in another array.
      void set(int[] index, double value)
      Sets the element at the given indexed position in a mutable array
      void set(int i, double value)
      Sets a value at a given position in a mutable 1D array
      void set(int i, int j, double value)
      Sets a value at a given position in a mutable 2D array
      void set(long[] index, double value)
      Sets the element at the given indexed position in a mutable array
      void set(java.lang.Object o)
      Sets this array to the element values contained in the given object.
      void setApplyOp(Op op, INDArray a)
      Sets this array to the result of applying an operation to a source array
      void setElements(double... values)
      Sets all elements in an array using the given double values
      void setElements(double[] values, int offset)
      Sets all elements in an array using the given double values
      void setElements(int pos, double[] values, int offset, int length)
      Sets elements in an array using the given double values.
      void setInnerProduct(INDArray a, INDArray b)
      Sets this array to the inner product of two arrays.
      void setMultiple(INDArray a, double b)
      Sets this array to be the multiple of another array.
      void setMultiple(INDArray a, INDArray b)
      Sets this array to the element-wise multiple of two arrays.
      void setSparse(double value)
      Sets the non-sparse elements of this array to the specified value May throw an exception if non-sparse elements are not mutable
      void setSparse(INDArray src)
      Sets the non-sparse elements of this array to the corresponding elements of the source array
      void signum()
      Calculates the signum of all elements of this mutable array Sets each component of the array to its sign value (-1, 0 or 1)
      INDArray signumCopy()
      Returns a copy of the array with the signum operator applied to each element
      INDArray slice(int majorSlice)
      Returns the specified major slice of this array as a view (slice along dimension 0) 0 dimensional slice results are permitted, but attempting to slice a 0 dimensional array will result in an error.
      INDArray slice(int dimension, int index)
      Returns a slice view of this array along the specified dimension
      int sliceCount()
      Returns the number of major slices in this array (i.e.
      java.lang.Object sliceValue(int majorSlice)
      Returns the value of a major slice of this array (slice along dimension 0) Like 'slice', except returns a Double value for slices of 1D vectors
      INDArray sparse()
      Coerces this INDArray to a sparse format, without changing its element values.
      INDArray sparseClone()
      Creates a fully mutable clone of this array.
      void sqrt()
      Computes the square root of all elements in the array
      void square()
      Squares all elements of the array in place
      INDArray squareCopy()
      Squares all elements of the array, returning a new array
      void sub(double a)
      Subtracts a double value from all elements in this array
      void sub(INDArray a)
      Subtracts all the elements of another array from this array, in an elementwise order.
      INDArray subArray(int[] offsets, int[] shape)
      Returns a subarray view of a larger array
      INDArray subCopy(INDArray a)
      Creates a new array equal to the subtraction of another array from this array
      double[] toDoubleArray()
      Copies the elements of this array to a new double[] array.
      void toDoubleBuffer(java.nio.DoubleBuffer dest)
      Copies the elements of this INDArray to the specified double buffer.
      INDArray[] toSliceArray()
      Copies the slices of this array to a new INDArray[] Throws an error if the array has no slices (i.e.
      Vector toVector()
      Coerces the array into a flattened dense Vector, in row-major order.
      void validate()
      Validates the internal data structure of the INDArray.
      INDArray withComponents(INDArray... components)
      Returns a new array of the same shape/structure as the original but with the specified components.
      • Methods inherited from interface java.lang.Comparable

        compareTo
    • Method Detail

      • dimensionality

        int dimensionality()
        Returns the dimensionality of the array (i.e. the number of dimensions in the array shape) e.g. 0 for a scalar, 1 for a vector, 2 for a matrix etc.
      • getShape

        int[] getShape()
        Returns the shape of the array as an array of ints. WARNING: May return the internal int[] array describing the shape. Modifying this may cause undefined behaviour. If you want to guarantee a new int[] array that can be safely modified, use getShapeClone() instead
      • getShapeClone

        int[] getShapeClone()
        Returns the shape of the array as an array of ints, guaranteed to be a new array i.e. will perform a defensive copy of any internal shape array if required.
      • getShape

        int getShape(int dim)
        Returns the dimension size for a specific dimension in the array's shape
        Throws:
        java.lang.IndexOutOfBoundsException - if the dimension does not exist.
      • getLongShape

        long[] getLongShape()
        Returns the shape of the array as an array of longs.
      • get

        double get(AIndex ix)
        Returns the double value at the specified position in the array
      • get

        double get(Index ix)
        Returns the double value at the specified position in the array
      • get

        double get()
        Returns the double value of a scalar array
      • get

        double get(int x)
        Returns the double value at the specified position in a 1D vector
      • get

        double get(long x)
        Returns the double value at the specified position in a 1D vector
      • get

        double get(int x,
                   int y)
        Returns the double value at the specified position in a 2D matrix
      • get

        double get(long x,
                   long y)
        Returns the double value at the specified position in a 2D matrix
      • get

        double get(int... indexes)
        Returns the double value at the specified index position in an array
      • get

        double get(long[] indexes)
        Returns the double value at the specified index position in an array
      • set

        void set(double value)
        Sets all elements of an array to a specific double value
      • set

        void set(int i,
                 double value)
        Sets a value at a given position in a mutable 1D array
        Parameters:
        i -
        value -
      • set

        void set(int i,
                 int j,
                 double value)
        Sets a value at a given position in a mutable 2D array
        Parameters:
        i -
        value -
      • set

        void set(int[] index,
                 double value)
        Sets the element at the given indexed position in a mutable array
        Parameters:
        index -
        value -
      • set

        void set(long[] index,
                 double value)
        Sets the element at the given indexed position in a mutable array
        Parameters:
        index -
        value -
      • set

        void set(INDArray a)
        Sets this array to the element values contained in another array. Broadcasts the source array if necessary to the shape of this array. Throws an exception if the shapes are incompatible.
      • set

        void set(java.lang.Object o)
        Sets this array to the element values contained in the given object. Attempts to interpret the object as an array, and broadcasts the object to the shape of this array if required.
      • add

        void add(double a)
        Adds a double value to all elements in this array. Implementations may optimize the case of 0.0
      • addCopy

        INDArray addCopy(INDArray a)
        Creates a new array equal to the sum of this array with another array.
        Parameters:
        a -
        Returns:
      • addCopy

        INDArray addCopy(double d)
        Creates a new array equal to this array with a constant value added to every element
        Parameters:
        a -
        Returns:
      • addToArray

        void addToArray(double[] data,
                        int offset)
        Adds all the elements of this array to a double array at the specified offset, in row-major order
      • sub

        void sub(double a)
        Subtracts a double value from all elements in this array
      • subCopy

        INDArray subCopy(INDArray a)
        Creates a new array equal to the subtraction of another array from this array
        Parameters:
        a -
        Returns:
      • add

        void add(INDArray a)
        Adds all the elements of another array to this array, in an elementwise order.
      • addAt

        void addAt(long i,
                   double v)
        Adds to a mutable array, indexed by element position in row major order. This is an unsafe operation: bounds are not checked
      • sub

        void sub(INDArray a)
        Subtracts all the elements of another array from this array, in an elementwise order.
      • fill

        void fill(double value)
        Fills this array with a single double value. Requires the array to be mutable.
      • negate

        void negate()
        Negates all elements in the array in place
      • negateCopy

        INDArray negateCopy()
        Negates all elements in the array, returning a new array
      • reciprocal

        void reciprocal()
        Replaces all elements in the array with their reciprocal
      • reciprocalCopy

        INDArray reciprocalCopy()
        Returns a new array where every element is the reciprocal of the corresponding element in this array
      • clamp

        void clamp(double min,
                   double max)
        Clamps all the elements of this array within the specified [min,max] range
      • innerProduct

        INDArray innerProduct(INDArray a)
        Calculates the inner product of this array with another array.
      • innerProduct

        INDArray innerProduct(double a)
        Calculates the inner product of this array with a double value
      • innerProduct

        INDArray innerProduct(AScalar a)
        Calculates the inner product of this array with a scalar
      • outerProduct

        INDArray outerProduct(INDArray a)
        Calculates the outer product of this array with another array.
      • asVector

        AVector asVector()
        Constructs a view of all elements in the array as a single vector in row-major order.
      • asElementList

        java.util.List<java.lang.Double> asElementList()
        Returns a List containing all elements of this array
      • reshape

        INDArray reshape(int... shape)
        Returns a new array by rearranging the elements of this array into the desired shape Truncates or zero-pads the elements as required to fill the new shape
      • reorder

        INDArray reorder(int dimension,
                         int[] order)
        Returns a re-ordered array by taking the specified order of slices along a given dimension May or may not use views of underlying slices (i.e. may be a reordered view)
      • reorder

        INDArray reorder(int[] order)
        Returns a re-ordered array by taking the specified order of slices along dimension 0
      • rotateView

        INDArray rotateView(int dimension,
                            int shift)
        Returns rotated view of this array
      • broadcast

        INDArray broadcast(int... shape)
        Returns a view of this array broadcasted up to a larger shape
      • broadcastLike

        INDArray broadcastLike(INDArray target)
        Broadcasts an array to match the shape of the target
        Parameters:
        target - The target array
        Throws:
        java.lang.IllegalArgumentException - if this array cannot be broadcasted to match the target
      • broadcastLike

        AMatrix broadcastLike(AMatrix target)
        Broadcasts an array to match the shape of the target matrix
        Parameters:
        target - The target matrix
        Throws:
        java.lang.IllegalArgumentException - if this array cannot be broadcasted to match the target
      • broadcastLike

        AVector broadcastLike(AVector target)
        Broadcasts an array to match the shape of the target vector
        Parameters:
        target - The target vector
        Throws:
        java.lang.IllegalArgumentException - if this array cannot be broadcasted to match the target
      • broadcastCloneLike

        INDArray broadcastCloneLike(INDArray target)
        Creates a mutable clone of the array, broadcasted upwards if necessary to match the shape of the target. If no upwards broadcasting is required, returns a regular clone() of this array.
        Parameters:
        target - The target array
        Throws:
        java.lang.IllegalArgumentException - if the array cannot be broadcasted to match the target or vice versa
      • broadcastCopyLike

        INDArray broadcastCopyLike(INDArray target)
        Creates a copy of the array, broadcasted upwards if necessary to match the shape of the target Like broadCastCloneLike, but does not guarantee a fully mutable clone - hence may be faster when used with immutable or specialized arrays
        Parameters:
        target - The target array
        Throws:
        java.lang.IllegalArgumentException - if the array cannot be broadcasted to match the target or vice versa
      • slice

        INDArray slice(int majorSlice)
        Returns the specified major slice of this array as a view (slice along dimension 0) 0 dimensional slice results are permitted, but attempting to slice a 0 dimensional array will result in an error.
        Throws:
        java.lang.RuntimeException - if the slice does not exist
      • sliceValue

        java.lang.Object sliceValue(int majorSlice)
        Returns the value of a major slice of this array (slice along dimension 0) Like 'slice', except returns a Double value for slices of 1D vectors
        Throws:
        java.lang.IndexOutOfBoundsException - if the slice does not exist
      • join

        INDArray join(INDArray a,
                      int dimension)
        Joins an array with another array along a specified dimension. Guarantees a view that combines the two joined arrays.
      • join

        INDArray join(INDArray a)
        Joins an array with another array along the major dimension Guarantees a view that combines the two joined arrays.
      • slice

        INDArray slice(int dimension,
                       int index)
        Returns a slice view of this array along the specified dimension
      • subArray

        INDArray subArray(int[] offsets,
                          int[] shape)
        Returns a subarray view of a larger array
      • getTranspose

        INDArray getTranspose()
        Returns the transpose of this array. A transpose of an array is equivalent to reversing the order of dimensions. May or may not return a view depending on the array type.
      • getTransposeView

        INDArray getTransposeView()
        Returns a transposed view of the array. May throw UnsupportedOperationException if the array type does not support this capability
      • getTransposeCopy

        INDArray getTransposeCopy()
        Returns a transposed copy of the array. Guarantees a new defensive copy.
      • sliceCount

        int sliceCount()
        Returns the number of major slices in this array (i.e. the size of dimension 0)
      • elementCount

        long elementCount()
        Returns the total number of elements in this array. Equivalent to the product of all dimension sizes.
      • elementSum

        double elementSum()
        Returns the sum of all elements in this array.
      • elementMax

        double elementMax()
        Returns the maximum element value in this array. Throws an error if there are no elements.
      • elementMaxAbs

        double elementMaxAbs()
        Returns the maximum absolute element value in this array. Throws an error if there are no elements.
      • elementMin

        double elementMin()
        Returns the maximum element value in this array. Throws an error if there are no elements.
      • elementSquaredSum

        double elementSquaredSum()
        Returns the sum of squared elements in this array.
      • elementIterator

        java.util.Iterator<java.lang.Double> elementIterator()
        Returns an iterator over all elements in this array, in row-major order
      • multiply

        void multiply(INDArray a)
        Multiplies all elements by the equivalent elements in a second array, i.e. performs elementwise multiplication. If matrix-style multiplication is required, use innerProduct instead.
      • multiplyCopy

        INDArray multiplyCopy(INDArray a)
        Multiplies all elements by the equivalent elements in a second array, i.e. performs elementwise multiplication. Returns a new array. If matrix-style multiplication is required, use innerProduct instead.
      • divide

        void divide(INDArray a)
        Divides all elements in place by the equivalent elements in a second array
      • divideCopy

        INDArray divideCopy(INDArray a)
        Divides all elements by the equivalent elements in a second array. Returns a new array.
      • divide

        void divide(double factor)
        Divides all elements by a given factor
      • nonZeroCount

        long nonZeroCount()
        Returns the number of non-zero elements in the array.
      • isMutable

        boolean isMutable()
        Returns true if the INDArray is mutable (at least partially)
      • isBoolean

        boolean isBoolean()
        Returns true if the array is boolean (contains only 0.0 or 1.0 values)
      • isSparse

        boolean isSparse()
        Returns true if the array is in a sparse format
      • isDense

        boolean isDense()
        Returns true if the array is in a dense format. A dense format uses efficient storage proportional to the number of elements
      • isFullyMutable

        boolean isFullyMutable()
        If this method returns true, the INDArray is guaranteed to be fully mutable in all positions i.e. every position can store any valid double value
      • isElementConstrained

        boolean isElementConstrained()
        Returns true if this array has some constraints on element values
      • isSameShape

        boolean isSameShape(INDArray a)
        Returns true if this array is the same shape as another array
      • isView

        boolean isView()
        Return true if this array is considered as a view type. This indicates (but does not guarantee): a) Data is *likely* to be shared with other arrays, so mutation of one may affect others b) It is *unlikely* to be in the most efficient general purpose format isView is intended to be used as for heuristics. It should *not* be used where the outcome might affect correctness.
      • isZero

        boolean isZero()
        Returns true if the array is zero (all elements equal to zero)
      • clone

        INDArray clone()
        Returns a clone of the array data, as a new array which will be fully mutable and may be of a different class to the original. Clone should attempt to return the most efficient possible array type. Clone should preserve sparsity property where possible, but this is not guaranteed.
      • copy

        INDArray copy()
        Returns a defensive copy of the array data. Use this if the original array might change and you need a defensive copy. May return the same array if the original was immutable, otherwise will return a defensive copy.
      • ensureMutable

        INDArray ensureMutable()
        Ensures the array is a fully mutable representation. Returns either the same array or a new clone.
      • applyOp

        void applyOp(Op op)
        Applies a unary operator to all elements of the array (in-place)
      • applyOpCopy

        INDArray applyOpCopy(Op op)
        Applies a unary operator to all elements of the array (creating a new array)
      • applyOp

        void applyOp(IOperator operator)
        Applies a unary operator to all elements of the array (in-place)
        Parameters:
        operator - The operator to apply to the array
      • reduce

        double reduce(Op2 op,
                      double init)
        Reduces over all elements of the array in row-major order. Applies the operator to the initial/previous result at each step. Returns the final result.
      • reduce

        double reduce(Op2 op)
        Reduces over all elements of the array in row-major order. Applies the operator to the previous result at each step. Returns the final result.
      • equals

        boolean equals(INDArray a)
        Checks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTo
      • elementsEqual

        boolean elementsEqual(double value)
        Returns true if all elements are equal to a specific value
      • exactClone

        INDArray exactClone()
        Creates a deep clone of an array, using the same class implementation as the original array
        Returns:
        A clone of the original array
      • setElements

        void setElements(double... values)
        Sets all elements in an array using the given double values
        Parameters:
        values - Element values in a double[] array. There must be at least as many element values as elements in this array.
      • setElements

        void setElements(double[] values,
                         int offset)
        Sets all elements in an array using the given double values
        Parameters:
        values - Element values in a double[] array. There must be at least as many element values as elements in this array.
        offset - Position in the values array from which to start taking values.
      • setElements

        void setElements(int pos,
                         double[] values,
                         int offset,
                         int length)
        Sets elements in an array using the given double values. The source array must contain at least the specified length in terms of number of elements
        Parameters:
        pos - Offset into this array, expressed in terms of number of elements in row major order
        values - Element values in a double[] array. There must be at least as many element values as elements in this array.
        offset - Position in the values array from which to start taking values.
        length - Number of elements to set.
      • getElements

        void getElements(double[] dest,
                         int offset)
        Copies all elements of this array a double array at the specified offset
      • getElements

        void getElements(java.lang.Object[] dest,
                         int offset)
        Copies all elements of this array into an object array at the specified offset
      • getElements

        void getElements(double[] arr)
        Copies all elements of this INDArray to the specified double array
      • scale

        void scale(double factor)
        Scales all elements of the array in place by a given double value
      • scaleCopy

        @Deprecated
        INDArray scaleCopy(double factor)
        Deprecated. 
        Scales all elements of the array by a given double value, returning a new array
      • scaleAdd

        void scaleAdd(double factor,
                      double constant)
        Scales all elements of the array by a given double value and adds a constant value
      • scaleAdd

        void scaleAdd(double factor,
                      INDArray b,
                      double bfactor,
                      double constant)
        Scales all elements of the array by a given double value, adds a scaled second array and adds a constant value
      • addMultiple

        void addMultiple(INDArray src,
                         double factor)
        Adds a scaled multiple of another array to this array
        Parameters:
        src -
        factor -
      • addPower

        void addPower(INDArray src,
                      double exponent)
        Adds an array with all elements of the source array raised to the specified power
        Parameters:
        src -
        factor -
      • addPower

        void addPower(INDArray src,
                      double exponent,
                      double factor)
        Adds an array with all elements raised to the specified power and scaled by the given factor
        Parameters:
        src -
        factor -
      • addInnerProduct

        void addInnerProduct(INDArray a,
                             INDArray b)
        Adds the inner product of two arrays to this array.
        Parameters:
        a -
        b -
        Throws:
        java.lang.IllegalArgumentException - if the inner product is a different shape to this array
      • addInnerProduct

        void addInnerProduct(INDArray a,
                             INDArray b,
                             double d)
        Adds a scalar multiple of the inner product of two arrays to this array.
        Parameters:
        a -
        b -
        Throws:
        java.lang.IllegalArgumentException - if the inner product is a different shape to this array
      • addOuterProduct

        void addOuterProduct(INDArray a,
                             INDArray b)
        Adds the outer product of two arrays to this array.
        Parameters:
        a -
        b -
        Throws:
        java.lang.IllegalArgumentException - if the inner product is a different shape to this array
      • addOuterProductSparse

        void addOuterProductSparse(INDArray a,
                                   INDArray b)
        Adds the outer product of two arrays to this array. Only affects the mutable, non-sparse elements of this array.
        Parameters:
        a -
        b -
        Throws:
        java.lang.IllegalArgumentException - if the inner product is a different shape to this array
      • addApplyOp

        void addApplyOp(Op op,
                        INDArray a)
        Adds the result of applying an Op to another array to this array.
        Parameters:
        op - A Vectorz Op
        a -
      • setInnerProduct

        void setInnerProduct(INDArray a,
                             INDArray b)
        Sets this array to the inner product of two arrays. Must be the correct shape.
        Parameters:
        a -
        b -
        Throws:
        java.lang.IllegalArgumentException - if the inner product is a different shape to this array
      • setApplyOp

        void setApplyOp(Op op,
                        INDArray a)
        Sets this array to the result of applying an operation to a source array
      • setMultiple

        void setMultiple(INDArray a,
                         INDArray b)
        Sets this array to the element-wise multiple of two arrays. Must have compatible shapes.
        Parameters:
        a -
        b -
        Throws:
        java.lang.IllegalArgumentException - if the inner product is a different shape to this array
      • setMultiple

        void setMultiple(INDArray a,
                         double b)
        Sets this array to be the multiple of another array. Must have compatible shapes.
        Parameters:
        a -
        b -
        Throws:
        java.lang.IllegalArgumentException - if the inner product is a different shape to this array
      • setSparse

        void setSparse(INDArray src)
        Sets the non-sparse elements of this array to the corresponding elements of the source array
      • setSparse

        void setSparse(double value)
        Sets the non-sparse elements of this array to the specified value May throw an exception if non-sparse elements are not mutable
      • addSparse

        void addSparse(double c)
        Adds to the non-sparse elements of this array
      • addSparse

        void addSparse(INDArray a)
        Adds the corresponding elements of the source array the non-sparse elements of this array
      • addMultipleSparse

        void addMultipleSparse(INDArray src,
                               double factor)
        Adds a multiple of the source array to the non-sparse elements of this array
      • multiply

        void multiply(double factor)
        Multiplies all elements of the array in place by a given double value
      • pow

        void pow(double exponent)
        Raises all elements of the array to a specified power in place
      • square

        void square()
        Squares all elements of the array in place
      • squareCopy

        INDArray squareCopy()
        Squares all elements of the array, returning a new array
      • sqrt

        void sqrt()
        Computes the square root of all elements in the array
      • signum

        void signum()
        Calculates the signum of all elements of this mutable array Sets each component of the array to its sign value (-1, 0 or 1)
      • getSlices

        java.util.List<?> getSlices()
        Returns a list of all major slices of this array. Returns a list of Double values if a 1-dimensional array is sliced, otherwise a list of INDArray instances
      • getSlices

        java.util.List<?> getSlices(int dimension)
        Returns a list of all slices of this array along a given dimension. Returns a list of Double values if a 1-dimensional array is sliced, otherwise a list of INDArray instances
      • validate

        void validate()
        Validates the internal data structure of the INDArray. Throws an exception on failure. Failure indicates a serious bug and/or data corruption.
      • toDoubleBuffer

        void toDoubleBuffer(java.nio.DoubleBuffer dest)
        Copies the elements of this INDArray to the specified double buffer.
      • toDoubleArray

        double[] toDoubleArray()
        Copies the elements of this array to a new double[] array.
      • toSliceArray

        INDArray[] toSliceArray()
        Copies the slices of this array to a new INDArray[] Throws an error if the array has no slices (i.e. is zero-dimensional)
      • asDoubleArray

        double[] asDoubleArray()
        Returns the underlying double array representing the densely packed elements of this array. Modifications to this double array will change the original array. Returns null if there is no such array.
      • getSliceViews

        java.util.List<INDArray> getSliceViews()
        Returns a list of slices as mutable INDArray views. Note: will return a list of AScalar values when this array is a 1D vector
      • toVector

        Vector toVector()
        Coerces the array into a flattened dense Vector, in row-major order. May return the same array if it is already a Vector instance.
      • epsilonEquals

        boolean epsilonEquals(INDArray a)
        Tests if this array is approximately equal to another array. The arrays must have the same shape.
      • epsilonEquals

        boolean epsilonEquals(INDArray a,
                              double epsilon)
        Tests is this array is approximately equal to another array, up to a given tolerance (epsilon) The arrays must have the same shape
      • abs

        void abs()
        Replaces all elements of this array with their absolute values, according to Math.abs(double)
      • log

        void log()
        Computes the natural logarithm (in-place) for all array elements
      • exp

        void exp()
        Computes the function e^x (in-place) for all array elements
      • immutable

        INDArray immutable()
        Returns an immutable version of this array. May return the same array if already immutable. Guarantees a defensive copy if the array is mutable.
      • mutable

        INDArray mutable()
        Coerces this INDArray to a fully mutable format. May return the same INDArray if already fully mutable
      • sparse

        INDArray sparse()
        Coerces this INDArray to a sparse format, without changing its element values. May return the same INDArray if already sparse. May also mutate the internal structure of the original NDArray, or create a view over parts of the original INDArray. You should take a defensive copy of the original NDArray if any of this concerns you. The returned sparse array may not be fully mutable in all elements.
      • dense

        INDArray dense()
        Coerces this INDArray to a dense format, without changing its element values. May return the same INDArray if already dense. May also mutate the internal structure of the original NDArray, or create a view over parts of the original INDArray. You should take a defensive copy of the original NDArray if any of this concerns you. The returned dense array may not be fully mutable in all elements.
      • sparseClone

        INDArray sparseClone()
        Creates a fully mutable clone of this array. Will use a sparse format if possible.
      • denseClone

        INDArray denseClone()
        Creates a fully mutable dense clone of this array. Will always use a dense format, even if the array data is sparse.
      • equalsArray

        boolean equalsArray(double[] data)
        Returns true if the elements in this array exactly match the elements in the given array, in row-major order. Returns false otherwise.
        Parameters:
        data - Array of double element values to check for equality
        Returns:
      • equalsArray

        boolean equalsArray(double[] data,
                            int offset)
        Returns true if the elements in this array exactly match the elements in the given array, in row-major order
        Parameters:
        data - Array of double element values to check for equality
        offset - Offset into the data array
        Returns:
      • innerProduct

        INDArray innerProduct(AVector v)
        Computes the inner product of this array with a vector
        Parameters:
        v - A vector
        Returns:
        A new array representing the inner product
      • absCopy

        INDArray absCopy()
        Returns a copy of the array with the abs operator applied to each element
        Returns:
        A new array containing the absolute element values
      • absDiff

        void absDiff(INDArray a)
        Sets this array to the absolute values of the difference between this array and another
      • absDiffCopy

        INDArray absDiffCopy(INDArray a)
        Returns an array containing the absolute values of the difference between this array and another
        Returns:
        A new array containing the absolute element values
      • signumCopy

        INDArray signumCopy()
        Returns a copy of the array with the signum operator applied to each element
        Returns:
        A new array containing the signums of element values
      • getElements

        double[] getElements()
        Gets all elements of the array as a Java double[] array
        Returns:
        A Java double[] array containing all elements in row-major order
      • getElement

        double getElement(long i)
        Gets a specific element of this array, indexed in row-major order
        Returns:
        The element value
      • elementProduct

        double elementProduct()
        Returns the product of all elements in the array.
        Returns:
      • multiplyCopy

        INDArray multiplyCopy(double factor)
        Returns a copy of the array with all elements multiplied by a single constant value
        Parameters:
        factor - A scalar factor
        Returns:
        A new array, with all element values scaled by the given factor
      • divideCopy

        INDArray divideCopy(double d)
        Returns a copy of the array with all elements divided by a single constant value
        Parameters:
        factor - A scalar factor
        Returns:
        A new array, with all element values scaled by the given factor
      • hasUncountable

        boolean hasUncountable()
        Checks if the array has any uncountable element values (i.e. NaN or infinite)
        Returns:
        True if any element is this array is NaN or infinite, false otherwise
      • elementPowSum

        double elementPowSum(double p)
        Returns the sum of all the elements raised to a specified power
        Returns:
      • elementAbsPowSum

        double elementAbsPowSum(double p)
        Returns the sum of the absolute values of all the elements raised to a specified power
        Returns:
      • componentCount

        int componentCount()
        Returns the number of components of this array. May return 0 if components are not supported
        Returns:
      • getComponent

        INDArray getComponent(int k)
        Gets a component from the array at the specified index Will throw an error if components are not supported, or if the component is out of bounds as defined by 0 <= k
        Parameters:
        k -
        Returns:
      • withComponents

        INDArray withComponents(INDArray... components)
        Returns a new array of the same shape/structure as the original but with the specified components. Components must be of a compatible type and identical shape to the original components.
      • getComponents

        INDArray[] getComponents()
        Gets all components in a new array, with length componentCount();
        Returns:
      • applyOp

        void applyOp(Op2 op,
                     INDArray b)
        Applies a binary operator to this array and a second array. Broadcasts the second array to the shape of this array if required.
        Parameters:
        op -
        b -
      • applyOp

        void applyOp(Op2 op,
                     double b)
        Applies a binary operator to this array and a double value. Works as if the double value was broadcast to the shape of this array.
        Parameters:
        op -
        b -
      • reduceSlices

        AVector reduceSlices(Op2 op)
        Reduces each vector slice of the array by the given binary operator Reduces down to a single vector
        Parameters:
        op -
        b -
      • reduceSlices

        AVector reduceSlices(Op2 op,
                             double init)
        Reduces each slice of the array by the given binary operator. Results are returned in a vector with one element for each slice. Uses the specified initial value for reduction of each slice.
        Parameters:
        op -
        b -

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.