Chainer provides some facilities to make debugging easy.
~chainer.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.
chainer.utils.type_check.Expr chainer.utils.type_check.expect chainer.utils.type_check.TypeInfo chainer.utils.type_check.TypeInfoTuple
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.
chainer.gradient_check.check_backward chainer.gradient_check.numerical_grad
The assertions have same names as NumPy's ones. The difference from NumPy is that they can accept both numpy.ndarray
and cupy.ndarray
.
chainer.testing.assert_allclose
Chainer provides some utilities for testing its functions.
chainer.testing.unary_math_function_unittest