class chainer.Flag[source]

Ternary flag object for variables.

It takes three values: ON, OFF, and AUTO.

ON and OFF flag can be evaluated as a boolean value. These are converted to True and False, respectively. AUTO flag cannot be converted to boolean. In this case, ValueError is raised.

Parameters:name (str, bool, or None) –

Name of the flag. Following values are allowed:

  • 'on', 'ON', or True for ON value
  • 'off', 'OFF', or False for OFF value
  • 'auto', 'AUTO', or None for AUTO value
chainer.ON = ON

Equivalent to Flag(‘on’).

chainer.OFF = OFF

Equivalent to Flag(‘off’).

chainer.AUTO = AUTO

Equivalent to Flag(‘auto’).


Returns an aggregated flag given a sequence of flags.

If both ON and OFF are found, this function raises an error. Otherwise, either of ON and OFF that appeared is returned. If all flags are AUTO, then it returns AUTO.

Parameters:flags (sequence of Flag) – Input flags.
Returns:The result of aggregation.
Return type:Flag