pub struct SPSA { /* private fields */ }Expand description
SPSA (Simultaneous Perturbation Stochastic Approximation) optimizer.
A gradient-free method that estimates gradients using random perturbations. Particularly effective for noisy objective functions (e.g., hardware execution).
§Mathematical Description
$$g_k \approx \frac{f(\theta + c_k \Delta_k) - f(\theta - c_k \Delta_k)}{2 c_k} \Delta_k^{-1}$$
where $\Delta_k$ is a random perturbation vector with ±1 entries.
Implementations§
Source§impl SPSA
impl SPSA
Sourcepub fn with_a_const(self, a_const: f64) -> Self
pub fn with_a_const(self, a_const: f64) -> Self
Set the stability constant A.
Sourcepub fn estimate_gradient<F: ObjectiveFunction>(
&self,
objective: &F,
params: &[f64],
iteration: usize,
) -> Vec<f64>
pub fn estimate_gradient<F: ObjectiveFunction>( &self, objective: &F, params: &[f64], iteration: usize, ) -> Vec<f64>
Estimate gradient using simultaneous perturbation.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SPSA
impl RefUnwindSafe for SPSA
impl Send for SPSA
impl Sync for SPSA
impl Unpin for SPSA
impl UnwindSafe for SPSA
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
Mutably borrows from an owned value. Read more