pub struct Value<V: Differentiable> { /* private fields */ }Expand description
Public value handle for reverse-mode AD.
Value exposes a torch-like surface while keeping graph ownership hidden.
Internally it carries either a leaf gradient sink or an edge into a reverse
graph.
Implementations§
Source§impl<V: Differentiable + 'static> Value<V>
impl<V: Differentiable + 'static> Value<V>
Sourcepub fn requires_grad(&self) -> bool
pub fn requires_grad(&self) -> bool
Return whether this value participates in reverse-mode AD.
Sourcepub fn with_requires_grad(self, enabled: bool) -> Self
pub fn with_requires_grad(self, enabled: bool) -> Self
Return a new value handle with gradient tracking enabled or disabled.
Sourcepub fn grad(&self) -> AdResult<Option<V::Tangent>>
pub fn grad(&self) -> AdResult<Option<V::Tangent>>
Read the accumulated leaf gradient, if available.
Sourcepub fn backward(&self) -> AdResult<()>
pub fn backward(&self) -> AdResult<()>
Run reverse-mode backward with the default scalar cotangent seed.
Sourcepub fn backward_with_seed(&self, seed: V::Tangent) -> AdResult<()>
pub fn backward_with_seed(&self, seed: V::Tangent) -> AdResult<()>
Run reverse-mode backward with an explicit cotangent seed.
Sourcepub fn grad_wrt_with_seed(
&self,
seed: V::Tangent,
wrt: &[&Self],
) -> AdResult<Vec<Option<V::Tangent>>>
pub fn grad_wrt_with_seed( &self, seed: V::Tangent, wrt: &[&Self], ) -> AdResult<Vec<Option<V::Tangent>>>
Compute functional gradients with respect to the requested inputs.
Return whether self and other share any reachable reverse graph.
Auto Trait Implementations§
impl<V> !Freeze for Value<V>
impl<V> RefUnwindSafe for Value<V>where
V: RefUnwindSafe,
impl<V> Send for Value<V>
impl<V> Sync for Value<V>
impl<V> Unpin for Value<V>
impl<V> UnwindSafe for Value<V>where
V: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more