# set_detect_anomaly

Source: https://www.tensorplay.cn/docs/generated/tensorplay.autograd.anomaly_mode.set_detect_anomaly.html

# set_detect_anomaly

class tensorplay.autograd.anomaly_mode.set_detect_anomaly(mode: [bool](https://docs.python.org/3/library/functions.html#bool), check_nan: [bool](https://docs.python.org/3/library/functions.html#bool) = True)[[source]](../_modules/tensorplay/autograd/anomaly_mode.html#set_detect_anomaly)

Context-manager that sets the anomaly detection for the autograd engine on or off.

set_detect_anomaly will enable or disable the autograd anomaly detection
based on its argument mode.
It can be used as a context-manager or as a function.

See detect_anomaly above for details of the anomaly detection behaviour.

Parameters:

- mode ([bool](https://docs.python.org/3/library/functions.html#bool)) – Flag whether to enable anomaly detection ( True ), or disable ( False ).

- check_nan ([bool](https://docs.python.org/3/library/functions.html#bool)) – Flag whether to raise an error when the backward generate “nan”
