[−][src]Struct finalfrontier::SGD
Stochastic gradient descent
This data type applies stochastic gradient descent on sentences.
Methods
impl<T> SGD<T> where
T: Trainer,
[src]
T: Trainer,
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<'b, S>(&mut self, sentence: &S, lr: f32) where
S: ?Sized,
T: TrainIterFrom<'b, S> + Trainer + NegativeSamples,
&'a T::Focus: IntoIterator<Item = u64>,
T::Focus: WordIdx,
[src]
S: ?Sized,
T: TrainIterFrom<'b, S> + Trainer + NegativeSamples,
&'a T::Focus: IntoIterator<Item = u64>,
T::Focus: WordIdx,
Update the model parameters using the given sentence.
This applies a gradient descent step on the sentence, with the given learning rate.
Trait Implementations
Auto Trait Implementations
impl<T> Send for SGD<T> where
T: Send,
T: Send,
impl<T> Sync for SGD<T> where
T: Sync,
T: Sync,
impl<T> Unpin for SGD<T> where
T: Unpin,
T: Unpin,
impl<T> !UnwindSafe for SGD<T>
impl<T> !RefUnwindSafe for SGD<T>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,