pub struct GradientsParams { /* private fields */ }Expand description
Data type that contains gradients for parameters.
Implementations§
Source§impl GradientsParams
impl GradientsParams
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new GradientsParams.
Sourcepub fn from_grads<B: AutodiffBackend, M: AutodiffModule<B>>(
grads: B::Gradients,
module: &M,
) -> Self
pub fn from_grads<B: AutodiffBackend, M: AutodiffModule<B>>( grads: B::Gradients, module: &M, ) -> Self
Extract each tensor gradients for the given module.
Note: This consumes the gradients. See [‘from_module’] to extract gradients only for a specific module.
Sourcepub fn from_module<B: AutodiffBackend, M: AutodiffModule<B>>(
grads: &mut B::Gradients,
module: &M,
) -> Self
pub fn from_module<B: AutodiffBackend, M: AutodiffModule<B>>( grads: &mut B::Gradients, module: &M, ) -> Self
Extract each tensor gradients for the given module.
Sourcepub fn from_params<B: AutodiffBackend, M: AutodiffModule<B>>(
grads: &mut B::Gradients,
module: &M,
params: &[ParamId],
) -> Self
pub fn from_params<B: AutodiffBackend, M: AutodiffModule<B>>( grads: &mut B::Gradients, module: &M, params: &[ParamId], ) -> Self
Extract tensor gradients for the given module and given parameters.
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>(&mut self, id: ParamId) -> Option<Tensor<B, D>>where
B: Backend,
pub fn remove<B, const D: usize>(&mut 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.
Sourcepub fn to_device<B: AutodiffBackend, M: AutodiffModule<B>>(
self,
device: &B::Device,
module: &M,
) -> Self
pub fn to_device<B: AutodiffBackend, M: AutodiffModule<B>>( self, device: &B::Device, module: &M, ) -> Self
Change the device of each tensor gradients registered for the given module.
Trait Implementations§
Source§impl Debug for GradientsParams
impl Debug for GradientsParams
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 Freeze for GradientsParams
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().