fn
inference_mode
→Iterator[None]inference_mode()Context manager for inference-time autograd suppression.
Like no_grad but reserved for fully read-only
inference paths: the user guarantees that no in-place
mutation of autograd-tracked tensors will occur inside the
scope. In the current Lucid implementation
inference_mode is an alias for no_grad; the API
exists so that future versions can add stricter optimisations
(e.g. skipping version-counter tracking on in-place ops)
without changing user code.
Parameters
NoneNo description.
Notes
Mathematically equivalent to wrapping the inference forward pass in
so no part of can be reconstructed afterwards.
Examples
>>> import lucid
>>> from lucid.autograd import inference_mode
>>> x = lucid.tensor([1.0, 2.0], requires_grad=True)
>>> with inference_mode():
... y = x * 3
>>> y.requires_grad
False