pub struct Variable { /* private fields */ }
Expand description
Gradient-aware variable that can be optimized.
Implementations§
Source§impl Variable
impl Variable
Sourcepub const fn tensor(&self) -> &GradientTensor
pub const fn tensor(&self) -> &GradientTensor
Get the gradient tensor.
Sourcepub fn value(&self) -> Rc<dyn ArrayProtocol>
pub fn value(&self) -> Rc<dyn ArrayProtocol>
Get the value of the variable.
Sourcepub fn grad_2(&self) -> Option<Rc<dyn ArrayProtocol>>
pub fn grad_2(&self) -> Option<Rc<dyn ArrayProtocol>>
Get the gradient of the variable.
Sourcepub fn set_gradient(
&mut self,
gradient: Box<dyn ArrayProtocol>,
) -> CoreResult<()>
pub fn set_gradient( &mut self, gradient: Box<dyn ArrayProtocol>, ) -> CoreResult<()>
Set the gradient of the variable
Sourcepub fn set_value(&mut self, newvalue: Box<dyn ArrayProtocol>)
pub fn set_value(&mut self, newvalue: Box<dyn ArrayProtocol>)
Set the value of the variable (for updating during optimization).
Auto Trait Implementations§
impl Freeze for Variable
impl !RefUnwindSafe for Variable
impl !Send for Variable
impl !Sync for Variable
impl Unpin for Variable
impl !UnwindSafe for Variable
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> 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