pub struct Adafactor {
pub lr: Option<f32>,
pub eps: (Array, Array),
pub clip_threshold: Array,
pub decay_rate: Array,
pub beta1: AdafactorBeta1,
pub weight_decay: f32,
pub scale_parameter: bool,
pub relative_step: bool,
pub warmup_init: bool,
pub state: State<AdafactorState>,
}Expand description
The Adafactor optimizer.
Our Adafactor implementation follows the original paper: `Adafactor: Adaptive Learning Rates with Sublinear Memory Cost https://arxiv.org/abs/1804.04235
Fields§
§lr: Option<f32>The learning rate.
eps: (Array, Array)The first term is added to the square of the gradients to improve numerical stability.
Default to Adafactor::DEFAULT_EPS.
clip_threshold: ArrayClips the unscaled update. Default to Adafactor::DEFAULT_CLIP_THRESHOLD.
decay_rate: ArrayCoefficient for the running average of the squared gradient. Default to
Adafactor::DEFAULT_DECAY_RATE.
beta1: AdafactorBeta1If set then the first moment will be used.
weight_decay: f32The weight decay. Default to Adafactor::DEFAULT_WEIGHT_DECAY.
scale_parameter: boolIf true the learningRate will be scaled by max(eps.0, RMS(parameter)). Default to
Adafactor::DEFAULT_SCALE_PARAMETER.
relative_step: boolIf true the learningRate will be ignored and the relative step size will be
computed. Default to Adafactor::DEFAULT_RELATIVE_STEP.
warmup_init: boolIf true the relative step size will be calculated by the current step. Default to
Adafactor::DEFAULT_WARMUP_INIT.
state: State<AdafactorState>Inner state.
Implementations§
Source§impl Adafactor
impl Adafactor
Sourcepub const DEFAULT_LR: Option<f32> = None
pub const DEFAULT_LR: Option<f32> = None
Default value for lr
Sourcepub const DEFAULT_EPS: (f32, f32)
pub const DEFAULT_EPS: (f32, f32)
Default values for eps
Sourcepub const DEFAULT_CLIP_THRESHOLD: f32 = 1.0
pub const DEFAULT_CLIP_THRESHOLD: f32 = 1.0
Default value for clip_threshold
Sourcepub const DEFAULT_DECAY_RATE: f32 = -0.8
pub const DEFAULT_DECAY_RATE: f32 = -0.8
Default value for decay_rate
Sourcepub const DEFAULT_WEIGHT_DECAY: f32 = 0.0
pub const DEFAULT_WEIGHT_DECAY: f32 = 0.0
Default value for weight_decay
Sourcepub const DEFAULT_SCALE_PARAMETER: bool = true
pub const DEFAULT_SCALE_PARAMETER: bool = true
Default value for scale_parameter
Sourcepub const DEFAULT_RELATIVE_STEP: bool = true
pub const DEFAULT_RELATIVE_STEP: bool = true
Default value for relative_step
Sourcepub const DEFAULT_WARMUP_INIT: bool = false
pub const DEFAULT_WARMUP_INIT: bool = false
Default value for warmup_init
Sourcepub const DEFAULT_BETA1: Option<f32> = None
pub const DEFAULT_BETA1: Option<f32> = None
Default value for beta1
Trait Implementations§
Source§impl Buildable for Adafactor
impl Buildable for Adafactor
Source§type Builder = AdafactorBuilder
type Builder = AdafactorBuilder
Source§impl Builder<Adafactor> for AdafactorBuilder
impl Builder<Adafactor> for AdafactorBuilder
Source§impl Optimizer for Adafactor
impl Optimizer for Adafactor
Source§fn update_single(
&mut self,
key: &Rc<str>,
gradient: &Array,
parameter: &mut Array,
) -> Result<()>
fn update_single( &mut self, key: &Rc<str>, gradient: &Array, parameter: &mut Array, ) -> Result<()>
Source§fn update<M>(
&mut self,
model: &mut M,
gradients: impl Borrow<FlattenedModuleParam>,
) -> Result<()>where
M: ModuleParameters,
fn update<M>(
&mut self,
model: &mut M,
gradients: impl Borrow<FlattenedModuleParam>,
) -> Result<()>where
M: ModuleParameters,
Source§impl Updatable for Adafactor
impl Updatable for Adafactor
Source§fn state_projection(
&mut self,
) -> Result<StateProjection<'_>, StateProjectionError>
fn state_projection( &mut self, ) -> Result<StateProjection<'_>, StateProjectionError>
Source§impl Updatable for &mut Adafactor
impl Updatable for &mut Adafactor
Source§fn state_projection(
&mut self,
) -> Result<StateProjection<'_>, StateProjectionError>
fn state_projection( &mut self, ) -> Result<StateProjection<'_>, StateProjectionError>
Auto Trait Implementations§
impl !Send for Adafactor
impl !Sync for Adafactor
impl Freeze for Adafactor
impl RefUnwindSafe for Adafactor
impl Unpin for Adafactor
impl UnsafeUnpin for Adafactor
impl UnwindSafe for Adafactor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Option.