tf.contrib.eager.seterr(inf_or_nan=None)
Defined in tensorflow/python/eager/execution_callbacks.py
.
Set how abnormal conditions are handled by the default eager context.
Example:
tfe.seterr(inf_or_nan="raise") a = tf.constant(10.0) b = tf.constant(0.0) try: c = a / b # <-- Raises InfOrNanError. except Exception as e: print("Caught Exception: %s" % e) tfe.seterr(inf_or_nan="ignore") c = a / b # <-- Does NOT raise exception anymore.
inf_or_nan
: Set action for infinity (inf
) and NaN (nan
) values. Possible values: {"ignore", "print", "raise", "warn"}
. "ignore"
: take no action when inf
values appear. "print"
: print a warning to stdout
. "raise"
: raise an InfOrNanError
. "warn"
: print a warning using tf.logging.warn
. A value of None
leads to no change in the action of the condition.A dictionary of old actions.
ValueError
: If the value of any keyword arguments is invalid.
© 2018 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/eager/seterr