Class NDArrayCreationUtil


  • public class NDArrayCreationUtil
    extends Object
    • Method Detail

      • getAllTestMatricesWithShape

        public static List<Pair<INDArray,​String>> getAllTestMatricesWithShape​(char ordering,
                                                                                    int rows,
                                                                                    int cols,
                                                                                    int seed,
                                                                                    DataType dataType)
        Get an array of INDArrays (2d) all with the specified shape. Pair returned to aid debugging: String contains information on how to reproduce the matrix (i.e., which function, and arguments) Each NDArray in the returned array has been obtained by applying an operation such as transpose, tensorAlongDimension, etc to an original array.
      • getAllTestMatricesWithShape

        public static List<Pair<INDArray,​String>> getAllTestMatricesWithShape​(long rows,
                                                                                    long cols,
                                                                                    long seed,
                                                                                    DataType dataType)
        Get an array of INDArrays (2d) all with the specified shape. Pair returned to aid debugging: String contains information on how to reproduce the matrix (i.e., which function, and arguments) Each NDArray in the returned array has been obtained by applying an operation such as transpose, tensorAlongDimension, etc to an original array.
      • getTestMatricesWithVaryingShapes

        public static List<Pair<INDArray,​String>> getTestMatricesWithVaryingShapes​(int rank,
                                                                                         char order,
                                                                                         DataType dataType)
        Test utility to sweep shapes given a rank Given a rank will generate random test matrices that will cover all cases of a shape with a '1' anywhere in the shape as well a shape with random ints that are not 0 or 1 eg. rank 2: 1,1; 1,2; 2,1; 2,2; 3,4 Motivated by TADs that often hit bugs when a "1" occurs as the size of a dimension
        Parameters:
        rank - any rank including true scalars i.e rank >= 0
        order - what order array to return i.e 'c' or 'f' order arrays
        Returns:
        List of arrays and the shapes as strings
      • getTransposedMatrixWithShape

        public static Pair<INDArray,​String> getTransposedMatrixWithShape​(char ordering,
                                                                               int rows,
                                                                               int cols,
                                                                               int seed,
                                                                               DataType dataType)
      • getTransposedMatrixWithShape

        public static Pair<INDArray,​String> getTransposedMatrixWithShape​(long rows,
                                                                               long cols,
                                                                               long seed,
                                                                               DataType dataType)
      • getSubMatricesWithShape

        public static List<Pair<INDArray,​String>> getSubMatricesWithShape​(long rows,
                                                                                long cols,
                                                                                long seed,
                                                                                DataType dataType)
      • getSubMatricesWithShape

        public static List<Pair<INDArray,​String>> getSubMatricesWithShape​(char ordering,
                                                                                long rows,
                                                                                long cols,
                                                                                long seed,
                                                                                DataType dataType)
      • getTensorAlongDimensionMatricesWithShape

        public static List<Pair<INDArray,​String>> getTensorAlongDimensionMatricesWithShape​(char ordering,
                                                                                                 long rows,
                                                                                                 long cols,
                                                                                                 long seed,
                                                                                                 DataType dataType)
      • getTensorAlongDimensionMatricesWithShape

        public static List<Pair<INDArray,​String>> getTensorAlongDimensionMatricesWithShape​(long rows,
                                                                                                 long cols,
                                                                                                 long seed,
                                                                                                 DataType dataType)
      • getPermutedWithShape

        public static Pair<INDArray,​String> getPermutedWithShape​(char ordering,
                                                                       long rows,
                                                                       long cols,
                                                                       long seed,
                                                                       DataType dataType)
      • getPermutedWithShape

        public static Pair<INDArray,​String> getPermutedWithShape​(long rows,
                                                                       long cols,
                                                                       long seed,
                                                                       DataType dataType)
      • getReshapedWithShape

        public static Pair<INDArray,​String> getReshapedWithShape​(char ordering,
                                                                       long rows,
                                                                       long cols,
                                                                       long seed,
                                                                       DataType dataType)
      • getReshapedWithShape

        public static Pair<INDArray,​String> getReshapedWithShape​(long rows,
                                                                       long cols,
                                                                       long seed,
                                                                       DataType dataType)
      • getAll3dTestArraysWithShape

        public static List<Pair<INDArray,​String>> getAll3dTestArraysWithShape​(int seed,
                                                                                    int[] shape,
                                                                                    DataType dataType)
      • getAll3dTestArraysWithShape

        public static List<Pair<INDArray,​String>> getAll3dTestArraysWithShape​(long seed,
                                                                                    long[] shape,
                                                                                    DataType dataType)
      • get3dTensorAlongDimensionWithShape

        public static List<Pair<INDArray,​String>> get3dTensorAlongDimensionWithShape​(int seed,
                                                                                           int[] shape,
                                                                                           DataType dataType)
      • get3dTensorAlongDimensionWithShape

        public static List<Pair<INDArray,​String>> get3dTensorAlongDimensionWithShape​(long seed,
                                                                                           long[] shape,
                                                                                           DataType dataType)
      • getAll4dTestArraysWithShape

        public static List<Pair<INDArray,​String>> getAll4dTestArraysWithShape​(int seed,
                                                                                    long[] shape,
                                                                                    DataType dataType)
      • getAll4dTestArraysWithShape

        public static List<Pair<INDArray,​String>> getAll4dTestArraysWithShape​(int seed,
                                                                                    int[] shape,
                                                                                    DataType dataType)
      • get4dTensorAlongDimensionWithShape

        public static List<Pair<INDArray,​String>> get4dTensorAlongDimensionWithShape​(int seed,
                                                                                           int[] shape,
                                                                                           DataType dataType)
      • getAll5dTestArraysWithShape

        public static List<Pair<INDArray,​String>> getAll5dTestArraysWithShape​(int seed,
                                                                                    int[] shape,
                                                                                    DataType dataType)
      • get5dTensorAlongDimensionWithShape

        public static List<Pair<INDArray,​String>> get5dTensorAlongDimensionWithShape​(int seed,
                                                                                           int[] shape,
                                                                                           DataType dataType)
      • getAll6dTestArraysWithShape

        public static List<Pair<INDArray,​String>> getAll6dTestArraysWithShape​(int seed,
                                                                                    int[] shape,
                                                                                    DataType dataType)
      • getRandomBroadCastShape

        public static int[][] getRandomBroadCastShape​(long seed,
                                                      int rank,
                                                      int numShapes)
        Create an ndarray of
        Parameters:
        seed -
        rank -
        numShapes -
        Returns:
      • broadcastToShape

        public static int[] broadcastToShape​(int[] inputShapeWithOnes,
                                             long seed)
        Generate a random shape to broadcast to given a randomly generated shape with 1s in it as inputs
        Parameters:
        inputShapeWithOnes -
        seed -
        Returns:
      • broadcastToShape

        public static long[] broadcastToShape​(long[] inputShapeWithOnes,
                                              long seed)