[][src]Struct finalfrontier::SGD

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

Stochastic gradient descent

This data type applies stochastic gradient descent on sentences.

Methods

impl<T> SGD<T> where
    T: Trainer
[src]

pub fn into_model(self) -> TrainModel<T>[src]

pub fn new(model: TrainModel<T>) -> Self[src]

Construct a new SGD instance,

pub fn model(&self) -> &TrainModel<T>[src]

Get the training model associated with this SGD.

pub fn n_tokens_processed(&self) -> usize[src]

Get the number of tokens that are processed by this SGD.

pub fn train_loss(&self) -> f32[src]

Get the average training loss of this SGD.

This returns the average training loss over all instances seen by this SGD instance since its construction.

pub fn update_sentence<S>(&mut self, sentence: &S, lr: f32) where
    S: ?Sized,
    T: TrainIterFrom<S> + Trainer + NegativeSamples, 
[src]

Update the model parameters using the given sentence.

This applies a gradient descent step on the sentence, with the given learning rate.

Trait Implementations

impl<T: Clone> Clone for SGD<T>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

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

impl<T> Sync for SGD<T> where
    T: Sync

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.