mygrad.no_autodiff#
- mygrad.no_autodiff = <mygrad._utils.graph_tracking._NoAutoDiff object>#
Serves as a context manager and decorator for suspending all computational graph tracking.
Note that memory guarding does not occur in the no_autodiff context, so there is no need to nest this context with mem_guard_off.
Examples
Demonstrating
no_autodiff
as a context-manager>>> import mygrad as mg >>> with mg.no_autodiff: >>> # all computational graph tracking is suspended >>> # within the context >>> x = mg.arange(4.) >>> (4 * x).backward() # no autodiff will occur >>> x.grad is None
Demonstrating
no_autodiff
as a decorator>>> @mg.no_autodiff ... def func(): ... # No graph-tracking will occur within ... # the body of this function ... pass