Package org.nd4j.linalg.checkutil
Class NDArrayCreationUtil
- java.lang.Object
-
- org.nd4j.linalg.checkutil.NDArrayCreationUtil
-
public class NDArrayCreationUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int[]
broadcastToShape(int[] inputShapeWithOnes, long seed)
Generate a random shape to broadcast to given a randomly generated shape with 1s in it as inputsstatic long[]
broadcastToShape(long[] inputShapeWithOnes, long seed)
static List<Pair<INDArray,String>>
get3dPermutedWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get3dPermutedWithShape(long seed, long[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get3dReshapedWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get3dReshapedWithShape(long seed, long[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get3dSubArraysWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get3dSubArraysWithShape(long seed, long[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get3dTensorAlongDimensionWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get3dTensorAlongDimensionWithShape(long seed, long[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get4dPermutedWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get4dReshapedWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get4dSubArraysWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get4dTensorAlongDimensionWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get5dPermutedWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get5dReshapedWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get5dSubArraysWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get5dTensorAlongDimensionWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get6dPermutedWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get6dReshapedWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
get6dSubArraysWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
getAll3dTestArraysWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
getAll3dTestArraysWithShape(long seed, long[] shape, DataType dataType)
static List<Pair<INDArray,String>>
getAll4dTestArraysWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
getAll4dTestArraysWithShape(int seed, long[] shape, DataType dataType)
static List<Pair<INDArray,String>>
getAll5dTestArraysWithShape(int seed, int[] shape, DataType dataType)
static List<Pair<INDArray,String>>
getAll6dTestArraysWithShape(int seed, int[] shape, DataType dataType)
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.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.static Pair<INDArray,String>
getPermutedWithShape(char ordering, long rows, long cols, long seed, DataType dataType)
static Pair<INDArray,String>
getPermutedWithShape(long rows, long cols, long seed, DataType dataType)
static int[][]
getRandomBroadCastShape(long seed, int rank, int numShapes)
Create an ndarray ofstatic Pair<INDArray,String>
getReshapedWithShape(char ordering, long rows, long cols, long seed, DataType dataType)
static Pair<INDArray,String>
getReshapedWithShape(long rows, long cols, long seed, DataType dataType)
static List<Pair<INDArray,String>>
getSubMatricesWithShape(char ordering, long rows, long cols, long seed, DataType dataType)
static List<Pair<INDArray,String>>
getSubMatricesWithShape(long rows, long cols, long seed, DataType dataType)
static List<Pair<INDArray,String>>
getTensorAlongDimensionMatricesWithShape(char ordering, long rows, long cols, long seed, DataType dataType)
static List<Pair<INDArray,String>>
getTensorAlongDimensionMatricesWithShape(long rows, long cols, long seed, DataType dataType)
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.static Pair<INDArray,String>
getTransposedMatrixWithShape(char ordering, int rows, int cols, int seed, DataType dataType)
static Pair<INDArray,String>
getTransposedMatrixWithShape(long rows, long cols, long seed, DataType dataType)
-
-
-
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. Pairreturned 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. Pairreturned 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 >= 0order
- 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)
-
get3dSubArraysWithShape
public static List<Pair<INDArray,String>> get3dSubArraysWithShape(int seed, int[] shape, DataType dataType)
-
get3dSubArraysWithShape
public static List<Pair<INDArray,String>> get3dSubArraysWithShape(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)
-
get3dPermutedWithShape
public static List<Pair<INDArray,String>> get3dPermutedWithShape(int seed, int[] shape, DataType dataType)
-
get3dPermutedWithShape
public static List<Pair<INDArray,String>> get3dPermutedWithShape(long seed, long[] shape, DataType dataType)
-
get3dReshapedWithShape
public static List<Pair<INDArray,String>> get3dReshapedWithShape(int seed, int[] shape, DataType dataType)
-
get3dReshapedWithShape
public static List<Pair<INDArray,String>> get3dReshapedWithShape(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)
-
get4dSubArraysWithShape
public static List<Pair<INDArray,String>> get4dSubArraysWithShape(int seed, int[] shape, DataType dataType)
-
get4dTensorAlongDimensionWithShape
public static List<Pair<INDArray,String>> get4dTensorAlongDimensionWithShape(int seed, int[] shape, DataType dataType)
-
get4dPermutedWithShape
public static List<Pair<INDArray,String>> get4dPermutedWithShape(int seed, int[] shape, DataType dataType)
-
get4dReshapedWithShape
public static List<Pair<INDArray,String>> get4dReshapedWithShape(int seed, int[] shape, DataType dataType)
-
getAll5dTestArraysWithShape
public static List<Pair<INDArray,String>> getAll5dTestArraysWithShape(int seed, int[] shape, DataType dataType)
-
get5dSubArraysWithShape
public static List<Pair<INDArray,String>> get5dSubArraysWithShape(int seed, int[] shape, DataType dataType)
-
get5dTensorAlongDimensionWithShape
public static List<Pair<INDArray,String>> get5dTensorAlongDimensionWithShape(int seed, int[] shape, DataType dataType)
-
get5dPermutedWithShape
public static List<Pair<INDArray,String>> get5dPermutedWithShape(int seed, int[] shape, DataType dataType)
-
get5dReshapedWithShape
public static List<Pair<INDArray,String>> get5dReshapedWithShape(int seed, int[] shape, DataType dataType)
-
getAll6dTestArraysWithShape
public static List<Pair<INDArray,String>> getAll6dTestArraysWithShape(int seed, int[] shape, DataType dataType)
-
get6dSubArraysWithShape
public static List<Pair<INDArray,String>> get6dSubArraysWithShape(int seed, int[] shape, DataType dataType)
-
get6dPermutedWithShape
public static List<Pair<INDArray,String>> get6dPermutedWithShape(int seed, int[] shape, DataType dataType)
-
get6dReshapedWithShape
public static List<Pair<INDArray,String>> get6dReshapedWithShape(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)
-
-