pub struct AdaDelta<T: Float> { /* private fields */ }Expand description
AdaDelta optimizer configuration
AdaDelta adapts learning rates based on a moving window of gradient updates, instead of accumulating all past gradients. This eliminates the need for a manual learning rate parameter.
§Key Features
- No learning rate parameter required (uses adaptive rates)
- Uses exponentially decaying average of squared gradients
- Uses exponentially decaying average of squared parameter updates
- More robust to hyperparameter choice than AdaGrad
§Type Parameters
T: Floating-point type (f32 or f64)
Implementations§
Source§impl<T: Float> AdaDelta<T>
impl<T: Float> AdaDelta<T>
Sourcepub fn new(rho: T, epsilon: T) -> Result<Self>
pub fn new(rho: T, epsilon: T) -> Result<Self>
Create a new AdaDelta optimizer
§Arguments
rho: Decay rate for moving averages (typically 0.9-0.99)epsilon: Small constant for numerical stability (typically 1e-6 to 1e-8)
§Returns
Result containing the optimizer or validation error
§Example
use optirs_core::optimizers::AdaDelta;
let optimizer = AdaDelta::<f32>::new(0.95, 1e-6).expect("AdaDelta::<f32>::new succeeds");Sourcepub fn with_warmup_boost(self, boost: T, steps: usize) -> Result<Self>
pub fn with_warmup_boost(self, boost: T, steps: usize) -> Result<Self>
Enable an opt-in bootstrap multiplier for the first steps updates
Plain AdaDelta starts with E[Δθ²] = 0, so the first updates are on the order
of sqrt(epsilon) and progress is slow until the update accumulator warms up.
Setting a boost trades strict fidelity to the paper for a faster start.
The boost scales only the update that is applied to the parameters — the
value accumulated into E[Δθ²] remains the unboosted update, so the adaptive
learning rate stays a faithful estimate.
§Errors
Returns an error if boost is not strictly positive.
Sourcepub fn warmup_boost(&self) -> T
pub fn warmup_boost(&self) -> T
Returns the configured warmup boost multiplier (1 when disabled)
Sourcepub fn step<'a, P, G>(&mut self, params: P, grads: G) -> Result<Array1<T>>
pub fn step<'a, P, G>(&mut self, params: P, grads: G) -> Result<Array1<T>>
Perform a single optimization step
§Arguments
params: Current parameter valuesgrads: Gradient values
§Returns
Result containing updated parameters or error
§Algorithm
- Initialize accumulators on first step
- Update exponentially decaying average of squared gradients
- Compute RMS of gradients and previous updates
- Compute parameter update using adaptive learning rate
- Update exponentially decaying average of squared updates
- Apply parameter update
§Example
use optirs_core::optimizers::AdaDelta;
use scirs2_core::ndarray_ext::array;
let mut optimizer = AdaDelta::<f32>::new(0.95, 1e-6).expect("AdaDelta::<f32>::new succeeds");
let params = array![1.0, 2.0, 3.0];
let grads = array![0.1, 0.2, 0.3];
let updated_params = optimizer.step(params.view(), grads.view()).expect("optimizer.step succeeds");Sourcepub fn step_view(
&mut self,
params: ArrayView1<'_, T>,
grads: ArrayView1<'_, T>,
) -> Result<Array1<T>>
pub fn step_view( &mut self, params: ArrayView1<'_, T>, grads: ArrayView1<'_, T>, ) -> Result<Array1<T>>
Perform a single optimization step on borrowed views
This is the concrete implementation behind AdaDelta::step.
Sourcepub fn step_count(&self) -> usize
pub fn step_count(&self) -> usize
Get the number of optimization steps performed
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the optimizer state
Clears accumulated gradient and update history
Sourcepub fn rms_gradients(&self) -> Option<Array1<T>>
pub fn rms_gradients(&self) -> Option<Array1<T>>
Get the current RMS of gradients for each parameter
Returns None if no steps have been performed yet
Sourcepub fn rms_updates(&self) -> Option<Array1<T>>
pub fn rms_updates(&self) -> Option<Array1<T>>
Get the current RMS of parameter updates
Returns None if no steps have been performed yet
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for AdaDelta<T>where
T: Deserialize<'de> + Float,
impl<'de, T> Deserialize<'de> for AdaDelta<T>where
T: Deserialize<'de> + Float,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T> Optimizer<T, Dim<[usize; 1]>> for AdaDelta<T>
impl<T> Optimizer<T, Dim<[usize; 1]>> for AdaDelta<T>
Source§fn get_learning_rate(&self) -> T
fn get_learning_rate(&self) -> T
AdaDelta has no learning-rate hyperparameter; the effective per-parameter rate
is RMS[Δθ]/RMS[g]. This reports 1 as the nominal scale.
Source§fn set_learning_rate(&mut self, _learning_rate: T)
fn set_learning_rate(&mut self, _learning_rate: T)
AdaDelta derives its step size from its accumulators, so setting a learning
rate has no effect. The method exists to satisfy the Optimizer trait.
Auto Trait Implementations§
impl<T> Freeze for AdaDelta<T>where
T: Freeze,
impl<T> RefUnwindSafe for AdaDelta<T>where
T: RefUnwindSafe,
impl<T> Send for AdaDelta<T>where
T: Send,
impl<T> Sync for AdaDelta<T>where
T: Sync,
impl<T> Unpin for AdaDelta<T>where
T: Unpin,
impl<T> UnsafeUnpin for AdaDelta<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for AdaDelta<T>where
T: UnwindSafe + RefUnwindSafe,
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.