class_docstr: An utility API to create function_hook callbacks to check whether the outputs of all layers have NaN or inf as their values.
  During forward and backward execution, passed as function_hook,
  this API reports ValueError if at least one of all layer outputs has Nan or inf as its values.
  Otherwise, all tensors passed to next layer or function as is.
  
  Example:
  
  .. code-block:: python
  
      pred = model(...)
  
      from nnabla.utils.inspection import NanInfTracer
      nit = NanInfTracer(trace_inf=True, trace_nan=True, need_details=True)
  
      with nit.trace():
          pred.forward(function_post_hook=nit.forward_post_hook)
          pred.backward(function_post_hook=nit.backward_post_hook)
class_docstr_tok: ["An","utility","API","to","create","function_hook","callbacks","to","check","whether","the","outputs","of","all","layers","have","NaN","or","inf","as","their","values",".","During","forward","and","backward","execution",",","passed","as","function_hook",",","this","API","reports","ValueError","if","at","least","one","of","all","layer","outputs","has","Nan","or","inf","as","its","values",".","Otherwise",",","all","tensors","passed","to","next","layer","or","function","as","is",".","Example",":","..","code-block",":",":","python","pred","=","model","(","...",")","from","nnabla.utils.inspection","import","NanInfTracer","nit","=","NanInfTracer","(","trace_inf=True",",","trace_nan=True",",","need_details=True",")","with","nit.trace","(",")",":","pred.forward","(","function_post_hook=nit.forward_post_hook",")","pred.backward","(","function_post_hook=nit.backward_post_hook",")"]
docstr: Create context manager to check nan/inf existence by using with statement.
  Using this context manager, checking nan/inf is performed automatically just before exiting with scope.
  Unless you use this context manager, be sure to call .check() explicitly to check nan/inf.
  
  Example:
  
  .. code-block:: python
  
      nit = NanInfTracer()
      with nit.trace():
          pred.forward(function_post_hook=nit.forward_post_hook)
          pred.backward(function_post_hook=nit.backward_post_hook)
docstr_tok: ["Create","context","manager","to","check","nan\/inf","existence","by","using","with","statement",".","Using","this","context","manager",",","checking","nan\/inf","is","performed","automatically","just","before","exiting","with","scope",".","Unless","you","use","this","context","manager",",","be","sure","to","call",".check","(",")","explicitly","to","check","nan\/inf",".","Example",":","..","code-block",":",":","python","nit","=","NanInfTracer","(",")","with","nit.trace","(",")",":","pred.forward","(","function_post_hook=nit.forward_post_hook",")","pred.backward","(","function_post_hook=nit.backward_post_hook",")"]
code: def trace(self):
      """
      Create context manager to check nan/inf existence by using with statement.
      Using this context manager, checking nan/inf is performed automatically just before exiting with scope.
      Unless you use this context manager, be sure to call .check() explicitly to check nan/inf.
  
      Example:
  
      .. code-block:: python
  
          nit = NanInfTracer()
          with nit.trace():
              pred.forward(function_post_hook=nit.forward_post_hook)
              pred.backward(function_post_hook=nit.backward_post_hook)
      """
      # No need to release any resources at the end of this context manager
      yield self
      self.check()
  
file_path: nnabla/python/src/nnabla/utils/inspection/value_trace.py
imports: from __future__ import absolute_import
  from collections import OrderedDict
  from contextlib import contextmanager
  import nnabla.functions
  from .base import FunctionHookCallbackBase
label_desc: Use image node_id 7 for calling the NanInfTracer obj's underlying member method code with example usage: obj.trace() without return types