Class TestCase


  • public class TestCase
    extends Object
    • Constructor Detail

      • TestCase

        public TestCase​(SameDiff sameDiff)
        Parameters:
        sameDiff - SameDiff instance to test. Note: All of the required inputs should already be set
    • Method Detail

      • expectedOutput

        public TestCase expectedOutput​(@NonNull
                                       @NonNull String name,
                                       @NonNull
                                       @NonNull INDArray expected,
                                       double eps)
        Validate the output (forward pass) for a single variable using INDArray.equals(INDArray)
        Parameters:
        name - Name of the variable to check
        expected - Expected INDArray
        eps - the expected epsilon, defaults to 1e-3
      • expectedOutput

        public TestCase expectedOutput​(@NonNull
                                       @NonNull String name,
                                       @NonNull
                                       @NonNull INDArray expected)
        Validate the output (forward pass) for a single variable using INDArray.equals(INDArray)
        Parameters:
        name - Name of the variable to check
        expected - Expected INDArray
      • expectedOutputRelError

        public TestCase expectedOutputRelError​(@NonNull
                                               @NonNull String name,
                                               @NonNull
                                               @NonNull INDArray expected,
                                               double maxRelError,
                                               double minAbsError)
        Validate the output (forward pass) for a single variable using element-wise relative error: relError = abs(x-y)/(abs(x)+abs(y)), with x=y=0 case defined to be 0.0. Also has a minimum absolute error condition, which must be satisfied for the relative error failure to be considered legitimate
        Parameters:
        name - Name of the variable to check
        expected - Expected INDArray
        maxRelError - Maximum allowable relative error
        minAbsError - Minimum absolute error for a failure to be considered legitimate
      • expected

        public TestCase expected​(@NonNull
                                 @NonNull SDVariable var,
                                 @NonNull
                                 @NonNull INDArray output)
        Validate the output (forward pass) for a single variable using INDArray.equals(INDArray)
        Parameters:
        var - Variable to check
        output - Expected INDArray
      • expected

        public TestCase expected​(@NonNull
                                 @NonNull String name,
                                 @NonNull
                                 @NonNull INDArray output)
        Validate the output (forward pass) for a single variable using INDArray.equals(INDArray)
        Parameters:
        name - Name of the variable to check
        output - Expected INDArray
      • expected

        public TestCase expected​(String name,
                                 Function<INDArray,​String> validationFn)
        Parameters:
        name - The name of the variable to check
        validationFn - Function to use to validate the correctness of the specific Op. Should return null if validation passes, or an error message if the op validation fails
      • gradCheckSkipVariables

        public Set<String> gradCheckSkipVariables()
      • gradCheckSkipVariables

        public TestCase gradCheckSkipVariables​(String... toSkip)
        Specify the input variables that should NOT be gradient checked. For example, if an input is an integer index (not real valued) it should be skipped as such an input cannot be gradient checked
        Parameters:
        toSkip - Name of the input variables to skip gradient check for
      • assertConfigValid

        public void assertConfigValid()
      • testNameErrMsg

        public String testNameErrMsg()