Package org.nd4j.linalg.checkutil
Class CheckUtil
- java.lang.Object
-
- org.nd4j.linalg.checkutil.CheckUtil
-
public class CheckUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description CheckUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
checkAdd(INDArray first, INDArray second, double maxRelativeDifference, double minAbsDifference)
Same as checkMmul, but for matrix additionstatic boolean
checkDivManually(INDArray first, INDArray second, double maxRelativeDifference, double minAbsDifference)
static boolean
checkEntries(org.apache.commons.math3.linear.RealMatrix rmResult, INDArray result, double maxRelativeDifference, double minAbsDifference)
static boolean
checkEntries(INDArray expected, INDArray actual, double maxRelativeDifference, double minAbsDifference)
static boolean
checkGemm(INDArray a, INDArray b, INDArray c, boolean transposeA, boolean transposeB, double alpha, double beta, double maxRelativeDifference, double minAbsDifference)
static boolean
checkMmul(INDArray first, INDArray second, double maxRelativeDifference, double minAbsDifference)
Check first.mmul(second) using Apache commons math mmul.static boolean
checkMulManually(INDArray first, INDArray second, double maxRelativeDifference, double minAbsDifference)
static boolean
checkSubtract(INDArray first, INDArray second, double maxRelativeDifference, double minAbsDifference)
Same as checkMmul, but for matrix subtractionstatic INDArray
convertFromApacheMatrix(org.apache.commons.math3.linear.RealMatrix matrix, DataType dataType)
static org.apache.commons.math3.linear.RealMatrix
convertToApacheMatrix(INDArray matrix)
static void
printApacheMatrix(org.apache.commons.math3.linear.RealMatrix matrix)
static void
printFailureDetails(INDArray first, INDArray second, org.apache.commons.math3.linear.RealMatrix expected, INDArray actual, INDArray onCopies, String op)
static void
printFailureDetails(INDArray first, INDArray second, INDArray expected, INDArray actual, INDArray onCopies, String op)
static void
printGemmFailureDetails(INDArray a, INDArray b, INDArray c, boolean transposeA, boolean transposeB, double alpha, double beta, org.apache.commons.math3.linear.RealMatrix expected, INDArray actual, INDArray onCopies)
static void
printMatrixFullPrecision(INDArray matrix)
static void
printNDArrayHeader(INDArray array)
-
-
-
Method Detail
-
checkMmul
public static boolean checkMmul(INDArray first, INDArray second, double maxRelativeDifference, double minAbsDifference)
Check first.mmul(second) using Apache commons math mmul. Float/double matrices only.
Returns true if OK, false otherwise.
Checks each element according to relative error (|a-b|/(|a|+|b|); however absolute error |a-b| must also exceed minAbsDifference for it to be considered a failure. This is necessary to avoid instability near 0: i.e., Nd4j mmul might return element of 0.0 (due to underflow on float) while Apache commons math mmul might be say 1e-30 or something (using doubles). Throws exception if matrices can't be multiplied Checks each element of the result. If- Parameters:
first
- First matrixsecond
- Second matrixmaxRelativeDifference
- Maximum relative errorminAbsDifference
- Minimum absolute difference for failure- Returns:
- true if OK, false if result incorrect
-
checkGemm
public static boolean checkGemm(INDArray a, INDArray b, INDArray c, boolean transposeA, boolean transposeB, double alpha, double beta, double maxRelativeDifference, double minAbsDifference)
-
checkAdd
public static boolean checkAdd(INDArray first, INDArray second, double maxRelativeDifference, double minAbsDifference)
Same as checkMmul, but for matrix addition
-
checkSubtract
public static boolean checkSubtract(INDArray first, INDArray second, double maxRelativeDifference, double minAbsDifference)
Same as checkMmul, but for matrix subtraction
-
checkMulManually
public static boolean checkMulManually(INDArray first, INDArray second, double maxRelativeDifference, double minAbsDifference)
-
checkDivManually
public static boolean checkDivManually(INDArray first, INDArray second, double maxRelativeDifference, double minAbsDifference)
-
checkEntries
public static boolean checkEntries(org.apache.commons.math3.linear.RealMatrix rmResult, INDArray result, double maxRelativeDifference, double minAbsDifference)
-
checkEntries
public static boolean checkEntries(INDArray expected, INDArray actual, double maxRelativeDifference, double minAbsDifference)
-
convertToApacheMatrix
public static org.apache.commons.math3.linear.RealMatrix convertToApacheMatrix(INDArray matrix)
-
convertFromApacheMatrix
public static INDArray convertFromApacheMatrix(org.apache.commons.math3.linear.RealMatrix matrix, DataType dataType)
-
printFailureDetails
public static void printFailureDetails(INDArray first, INDArray second, org.apache.commons.math3.linear.RealMatrix expected, INDArray actual, INDArray onCopies, String op)
-
printGemmFailureDetails
public static void printGemmFailureDetails(INDArray a, INDArray b, INDArray c, boolean transposeA, boolean transposeB, double alpha, double beta, org.apache.commons.math3.linear.RealMatrix expected, INDArray actual, INDArray onCopies)
-
printMatrixFullPrecision
public static void printMatrixFullPrecision(INDArray matrix)
-
printNDArrayHeader
public static void printNDArrayHeader(INDArray array)
-
printFailureDetails
public static void printFailureDetails(INDArray first, INDArray second, INDArray expected, INDArray actual, INDArray onCopies, String op)
-
printApacheMatrix
public static void printApacheMatrix(org.apache.commons.math3.linear.RealMatrix matrix)
-
-