Debug mode

In debug mode, Chainer checks values of variables on runtime and shows more detailed error messages. It helps you to debug your programs. Instead it requires additional overhead time.

In debug mode, Chainer checks all results of forward and backward computation, and if it founds a NaN value, it raises RuntimeError. Some functions and links also check validity of input values.

chainer.is_debug()[ソース]

Get the debug mode.

戻り値:Return True if Chainer is in debug mode.
戻り値の型:bool
chainer.set_debug(debug)[ソース]

Set the debug mode.

注釈

This method changes global state. When you use this method on multi-threading environment, it may affects other threads.

パラメータ:debug (bool) – New debug mode.
class chainer.DebugMode(debug)[ソース]

Debug mode context.

This class provides a context manager for debug mode. When entering the context, it sets the debug mode to the value of debug parameter with memorizing its original value. When exiting the context, it sets the debug mode back to the original value.

パラメータ:debug (bool) – Debug mode used in the context.