Struct tch::nn::Optimizer[][src]

pub struct Optimizer<T> { /* fields omitted */ }

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

impl<T: Debug> Debug for Optimizer<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Optimizer<T> where
    T: RefUnwindSafe

impl<T> Send for Optimizer<T> where
    T: Send

impl<T> !Sync for Optimizer<T>

impl<T> Unpin for Optimizer<T> where
    T: Unpin

impl<T> UnwindSafe for Optimizer<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,