Struct tch::nn::Optimizer [−][src]
An optimizer to run gradient descent.
Implementations
impl<T> Optimizer<T>
[src]
pub fn zero_grad(&mut self)
[src]
Zeroes the gradient for the tensors tracked by this optimizer.
pub fn clip_grad_value(&self, max: f64)
[src]
Clips gradient value at some specified maximum value.
pub fn clip_grad_norm(&self, max: f64)
[src]
Clips gradient L2 norm over all trainable parameters.
The norm is computed over all gradients together, as if they were concatenated into a single vector.
pub fn step(&mut self)
[src]
Performs an optimization step, updating the tracked tensors based on their gradients.
pub fn backward_step(&mut self, loss: &Tensor)
[src]
Applies a backward step pass, update the gradients, and performs an optimization step.
pub fn backward_step_clip(&mut self, loss: &Tensor, max: f64)
[src]
Applies a backward step pass, update the gradients, and performs an optimization step.
The gradients are clipped based on max
before being applied.
pub fn backward_step_clip_norm(&mut self, loss: &Tensor, max: f64)
[src]
Applies a backward step pass, update the gradients, and performs an optimization step.
The gradients L2 norm is clipped based on max
.
pub fn set_lr(&mut self, lr: f64)
[src]
Sets the optimizer learning rate.
pub fn set_momentum(&mut self, m: f64)
[src]
Sets the optimizer momentum.
pub fn set_lr_group(&mut self, group: usize, lr: f64)
[src]
Sets the optimizer learning rate for a parameter group.
pub fn set_momentum_group(&mut self, group: usize, m: f64)
[src]
Sets the optimizer momentum.
pub fn trainable_variables(&self) -> Vec<Tensor>
[src]
Returns all the trainable variables for this optimizer.
pub fn set_weight_decay(&mut self, weight_decay: f64)
[src]
Sets the optimizer weight decay.
pub fn set_weight_decay_group(&mut self, group: usize, weight_decay: f64)
[src]
Sets the optimizer weight decay.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Optimizer<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Optimizer<T> where
T: Send,
T: Send,
impl<T> !Sync for Optimizer<T>
impl<T> Unpin for Optimizer<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Optimizer<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,