Struct burn_core::optim::GradientsParams
source · pub struct GradientsParams { /* private fields */ }Expand description
Data type that contains gradients for parameters.
Implementations§
source§impl GradientsParams
impl GradientsParams
pub fn new() -> Self
sourcepub fn get<B, const D: usize>(&self, id: &ParamId) -> Option<Tensor<B, D>>where
B: Backend,
pub fn get<B, const D: usize>(&self, id: &ParamId) -> Option<Tensor<B, D>>where B: Backend,
Get the gradients for the given parameter id.
Notes
You should use remove if you want to get the gradients only one time.
sourcepub fn remove<B, const D: usize>(&self, id: &ParamId) -> Option<Tensor<B, D>>where
B: Backend,
pub fn remove<B, const D: usize>(&self, id: &ParamId) -> Option<Tensor<B, D>>where B: Backend,
Remove the gradients for the given parameter id.
sourcepub fn register<B, const D: usize>(&mut self, id: ParamId, value: Tensor<B, D>)where
B: Backend,
pub fn register<B, const D: usize>(&mut self, id: ParamId, value: Tensor<B, D>)where B: Backend,
Register a gradients tensor for the given parameter id.
Notes
If a tensor is already registered for the given parameter id, it will be replaced.
Trait Implementations§
source§impl Default for GradientsParams
impl Default for GradientsParams
source§fn default() -> GradientsParams
fn default() -> GradientsParams
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for GradientsParams
impl Send for GradientsParams
impl Sync for GradientsParams
impl Unpin for GradientsParams
impl !UnwindSafe for GradientsParams
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