pub struct GradientTensor { /* private fields */ }
Expand description
Tensor with gradient tracking capabilities.
Implementations§
Source§impl GradientTensor
impl GradientTensor
Sourcepub fn new(value: Rc<dyn ArrayProtocol>, requiresgrad: bool) -> Self
pub fn new(value: Rc<dyn ArrayProtocol>, requiresgrad: bool) -> Self
Create a new gradient tensor from a value.
Sourcepub fn from_array<T, D>(array: Array<T, D>, requiresgrad: bool) -> Self
pub fn from_array<T, D>(array: Array<T, D>, requiresgrad: bool) -> Self
Create a new gradient tensor from an array.
Sourcepub fn value(&self) -> Rc<dyn ArrayProtocol>
pub fn value(&self) -> Rc<dyn ArrayProtocol>
Get the value of the tensor.
Sourcepub fn grad_2(&self) -> Option<Rc<dyn ArrayProtocol>>
pub fn grad_2(&self) -> Option<Rc<dyn ArrayProtocol>>
Get the gradient of the tensor.
Sourcepub fn requiresgrad(&self) -> bool
pub fn requiresgrad(&self) -> bool
Check if gradient computation is required for this tensor.
Sourcepub fn set_requiresgrad(&mut self, requiresgrad: bool)
pub fn set_requiresgrad(&mut self, requiresgrad: bool)
Set whether gradient computation is required for this tensor.
Sourcepub fn set_value(&mut self, newvalue: Rc<dyn ArrayProtocol>)
pub fn set_value(&mut self, newvalue: Rc<dyn ArrayProtocol>)
Set the value of the tensor (for updating variables during optimization).
Sourcepub fn backward(&self) -> CoreResult<()>
pub fn backward(&self) -> CoreResult<()>
Backward pass to compute gradients.
Trait Implementations§
Source§impl Clone for GradientTensor
impl Clone for GradientTensor
Source§fn clone(&self) -> GradientTensor
fn clone(&self) -> GradientTensor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for GradientTensor
impl !RefUnwindSafe for GradientTensor
impl !Send for GradientTensor
impl !Sync for GradientTensor
impl Unpin for GradientTensor
impl !UnwindSafe for GradientTensor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more