Package org.nd4j.autodiff.validation
Class TestCase
- java.lang.Object
-
- org.nd4j.autodiff.validation.TestCase
-
public class TestCase extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTestCase.TestSerialization
-
Field Summary
Fields Modifier and Type Field Description static booleanGC_DEFAULT_DEBUG_MODEstatic doubleGC_DEFAULT_EPSstatic booleanGC_DEFAULT_EXIT_FIRST_FAILUREstatic doubleGC_DEFAULT_MAX_REL_ERRORstatic doubleGC_DEFAULT_MIN_ABS_ERRORstatic booleanGC_DEFAULT_PRINT
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertConfigValid()TestCaseexpected(@NonNull String name, @NonNull INDArray output)Validate the output (forward pass) for a single variable using INDArray.equals(INDArray)TestCaseexpected(@NonNull SDVariable var, @NonNull INDArray output)Validate the output (forward pass) for a single variable using INDArray.equals(INDArray)TestCaseexpected(String name, Function<INDArray,String> validationFn)TestCaseexpected(SDVariable var, Function<INDArray,String> validationFn)TestCaseexpectedOutput(@NonNull String name, @NonNull INDArray expected)Validate the output (forward pass) for a single variable using INDArray.equals(INDArray)TestCaseexpectedOutput(@NonNull String name, @NonNull INDArray expected, double eps)Validate the output (forward pass) for a single variable using INDArray.equals(INDArray)TestCaseexpectedOutputRelError(@NonNull String name, @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.Map<String,INDArray>gradCheckMask()Set<String>gradCheckSkipVariables()TestCasegradCheckSkipVariables(String... toSkip)Specify the input variables that should NOT be gradient checked.TestCaseplaceholderValue(String variable, INDArray value)TestCaseplaceholderValues(Map<String,INDArray> placeholderValues)StringtestNameErrMsg()
-
-
-
Field Detail
-
GC_DEFAULT_PRINT
public static final boolean GC_DEFAULT_PRINT
- See Also:
- Constant Field Values
-
GC_DEFAULT_EXIT_FIRST_FAILURE
public static final boolean GC_DEFAULT_EXIT_FIRST_FAILURE
- See Also:
- Constant Field Values
-
GC_DEFAULT_DEBUG_MODE
public static final boolean GC_DEFAULT_DEBUG_MODE
- See Also:
- Constant Field Values
-
GC_DEFAULT_EPS
public static final double GC_DEFAULT_EPS
- See Also:
- Constant Field Values
-
GC_DEFAULT_MAX_REL_ERROR
public static final double GC_DEFAULT_MAX_REL_ERROR
- See Also:
- Constant Field Values
-
GC_DEFAULT_MIN_ABS_ERROR
public static final double GC_DEFAULT_MIN_ABS_ERROR
- See Also:
- Constant Field Values
-
-
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 checkexpected- Expected INDArrayeps- 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 checkexpected- 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 checkexpected- Expected INDArraymaxRelError- Maximum allowable relative errorminAbsError- 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 checkoutput- 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 checkoutput- Expected INDArray
-
expected
public TestCase expected(SDVariable var, Function<INDArray,String> validationFn)
-
expected
public TestCase expected(String name, Function<INDArray,String> validationFn)
- Parameters:
name- The name of the variable to checkvalidationFn- 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 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()
-
-