Skip to main content

StepDecay

Struct StepDecay 

Source
pub struct StepDecay<V> {
    pub interval: u32,
    pub factor: V,
    /* private fields */
}
Expand description

Step-decay learning-rate schedule (C++ StepDecaySchedule): every interval training steps the learning rate is multiplied by factor.

A network trained with Scheduled calls step after each weight update, so the rate used by update n (counting from 1) is the initial rate times factor^((n - 1) / interval), each product rounded as the value type rounds. An interval of 0 decays after every step, as 1 does.

StepDecay::<Q16_16>::default() and StepDecay::<Q8_8>::default() are tinymind (C++)’s defaults: interval 1000 and factor 0.9 rounded to the format (58982/65536 and 230/256). The counts are u32 (C++ size_t), so the schedule is the same size on a microcontroller and a 64-bit host.

Fields§

§interval: u32

Training steps between two decays.

§factor: V

What the learning rate is multiplied by at each decay.

Implementations§

Source§

impl<V> StepDecay<V>

Source

pub const fn new(interval: u32, factor: V) -> Self

A schedule that multiplies the rate by factor every interval steps, starting its count at 0.

Source

pub fn steps_since_decay(&self) -> u32

Steps counted since the last decay (or since the start).

Source§

impl<V: Scalar> StepDecay<V>

Source

pub fn step(&mut self, rate: V) -> V

Count one training step and return the learning rate for the next one: rate * factor when this step completes an interval, else rate.

Trait Implementations§

Source§

impl<V: Clone> Clone for StepDecay<V>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Copy> Copy for StepDecay<V>

Source§

impl<V: Debug> Debug for StepDecay<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StepDecay<Q16_16>

Source§

fn default() -> Self

tinymind (C++)’s Q16.16 default: interval 1000, factor 58982/65536.

Source§

impl Default for StepDecay<Q8_8>

Source§

fn default() -> Self

tinymind (C++)’s Q8.8 default: interval 1000, factor 230/256.

Source§

impl<V: Eq> Eq for StepDecay<V>

Source§

impl<V: PartialEq> PartialEq for StepDecay<V>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<V: PartialEq> StructuralPartialEq for StepDecay<V>

Auto Trait Implementations§

§

impl<V> Freeze for StepDecay<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for StepDecay<V>
where V: RefUnwindSafe,

§

impl<V> Send for StepDecay<V>
where V: Send,

§

impl<V> Sync for StepDecay<V>
where V: Sync,

§

impl<V> Unpin for StepDecay<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for StepDecay<V>
where V: UnsafeUnpin,

§

impl<V> UnwindSafe for StepDecay<V>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.