fn
detach
→Tensordetach(impl: Tensor)Return a tensor that shares data but is detached from the autograd graph.
The returned tensor has requires_grad=False and is no longer a leaf
of any computation; gradients flowing into it during backward will be
silently dropped. Storage is shared, so mutating the detached view
will affect the original (and may invalidate saved tensors).
Parameters
implTensorSource tensor.
Returns
TensorDetached view sharing storage with impl.
Notes
Common idiom for capturing intermediate values for logging without
holding graph references that would inhibit memory reclamation. Pair
with clone (i.e. x.detach().clone()) when you also need an
independent buffer.
Examples
>>> import lucid
>>> x = lucid.tensor([1.0, 2.0], requires_grad=True)
>>> y = lucid.detach(x)
>>> y.requires_grad
False