Struct burn::optim::GradientsParams
pub struct GradientsParams { /* private fields */ }
Expand description
Data type that contains gradients for parameters.
Implementations§
§impl GradientsParams
impl GradientsParams
pub fn new() -> GradientsParams
pub fn new() -> GradientsParams
Creates a new GradientsParams.
pub fn from_grads<B, M>(
grads: <B as AutodiffBackend>::Gradients,
module: &M,
) -> GradientsParamswhere
B: AutodiffBackend,
M: AutodiffModule<B>,
pub fn from_grads<B, M>(
grads: <B as AutodiffBackend>::Gradients,
module: &M,
) -> GradientsParamswhere
B: AutodiffBackend,
M: AutodiffModule<B>,
Extract each tensor gradients for the given module.
Note: This consumes the gradients. See [‘from_module’] to extract gradients only for a specific module.
pub fn from_module<B, M>(
grads: &mut <B as AutodiffBackend>::Gradients,
module: &M,
) -> GradientsParamswhere
B: AutodiffBackend,
M: AutodiffModule<B>,
pub fn from_module<B, M>(
grads: &mut <B as AutodiffBackend>::Gradients,
module: &M,
) -> GradientsParamswhere
B: AutodiffBackend,
M: AutodiffModule<B>,
Extract each tensor gradients for the given module.
pub fn from_params<B, M>(
grads: &mut <B as AutodiffBackend>::Gradients,
module: &M,
params: &[ParamId],
) -> GradientsParamswhere
B: AutodiffBackend,
M: AutodiffModule<B>,
pub fn from_params<B, M>(
grads: &mut <B as AutodiffBackend>::Gradients,
module: &M,
params: &[ParamId],
) -> GradientsParamswhere
B: AutodiffBackend,
M: AutodiffModule<B>,
Extract tensor gradients for the given module and given parameters.
pub 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.
pub 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.
pub 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.
pub fn to_device<B, M>(
self,
device: &<B as Backend>::Device,
module: &M,
) -> GradientsParamswhere
B: AutodiffBackend,
M: AutodiffModule<B>,
pub fn to_device<B, M>(
self,
device: &<B as Backend>::Device,
module: &M,
) -> GradientsParamswhere
B: AutodiffBackend,
M: AutodiffModule<B>,
Change the device of each tensor gradients registered for the given module.
Trait Implementations§
§impl Debug for GradientsParams
impl Debug for GradientsParams
§impl Default for GradientsParams
impl Default for GradientsParams
§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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<T> Pointable for T
impl<T> Pointable for T
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()
.