Assertion and Testing¶
Chainer provides some facilities to make debugging easy.
Type checking utilities¶
FunctionNode
uses a systematic type checking of the chainer.utils.type_check
module.
It enables users to easily find bugs of forward and backward implementations.
You can find examples of type checking in some function implementations.
Abstract syntax tree of an expression. |
|
Evaluates and tests all given expressions. |
|
Type information of an input/gradient array. |
|
Type information of input/gradient tuples. |
Gradient checking utilities¶
Most function implementations are numerically tested by gradient checking.
This method computes numerical gradients of forward routines and compares their results with the corresponding backward routines.
It enables us to make the source of issues clear when we hit an error of gradient computations.
The chainer.gradient_check
module makes it easy to implement the gradient checking.
Test backward procedure of a given function. |
|
Test twice differentiation of a given procedure. |
|
Computes numerical gradient by finite differences. |
Standard Assertions¶
The assertions have same names as NumPy’s ones.
The difference from NumPy is that they can accept both numpy.ndarray
and cupy.ndarray
.
Asserts if some corresponding element of x and y differs too much. |
|
Function testing utilities¶
Utilities for testing functions.
A base class for function test cases. |
|
Decorator for testing unary mathematical Chainer functions. |
Link testing utilities¶
Utilities for testing links.
A base class for link parameter initializer test cases. |
|
A base class for link forward and backward test cases. |
Serialization testing utilities¶
Utilities for testing serializable objects.
Saves |
|
Saves |
|
Saves |
Trainer Extension Testing Utilities¶
Utilities for testing trainer extensions.
Returns a |
Repeat decorators¶
These decorators have a decorated test run multiple times in a single invocation. Criteria of passing / failing of the test changes according to the type of decorators. See the documentation of each decorator for details.
Decorator for multiple trial of the test case. |
|
Decorator that imposes the test to be successful in a row. |
|
Decorator that imposes the test to be successful at least once. |
Unit test annotation¶
Decorators for annotating unit tests.
Decorator to indicate that GPU is required to run the test. |
|
Decorator to indicate number of GPUs required to run the test. |
|
Run a test case only when given requirements are satisfied. |
|
Decorator that fixes random numbers in a test. |