Skip to main content

GradientDescent

Struct GradientDescent 

Source
pub struct GradientDescent {
Show 16 fields pub iterations: usize, pub object_step: f64, pub batch_size: usize, pub epsilon: f64, pub loss_type: LossType, pub recover_illumination: bool, pub illumination_step: f64, pub illumination_finite_difference: f64, pub maximum_illumination_correction: f64, pub recover_pupil: bool, pub pupil_step: f64, pub constrain_pupil_support: bool, pub object_tv_weight: f64, pub object_tv_epsilon: f64, pub pupil_smoothing_weight: f64, pub parallel_workers: usize,
}
Expand description

Wirtinger-style loss-gradient reconstruction for Fourier ptychography.

§Method

The solver differentiates a selected real-valued data loss through the complex FPM forward model, accumulates gradients from a mini-batch, and applies a pupil-power-preconditioned update to the shared object spectrum. This is the Fourier-ptychographic Wirtinger-flow viewpoint: phase retrieval is treated as direct optimization rather than alternating hard projections. Losses are evaluated after accounting for known linear gain and background, so detector count scaling does not change the intrinsic update scale.

Optional extensions recover the pupil with an analogous normalized gradient, estimate illumination offsets with finite-difference derivatives and diagonal Gauss–Newton scaling, and regularize the complex object or pupil. Incoherent multiplexing, these calibration updates, and the selectable losses extend the reference formulation.

§Reference

L. Bian, J. Suo, G. Zheng, K. Guo, F. Chen, and Q. Dai, “Fourier ptychographic reconstruction using Wirtinger flow optimization,” Optics Express 23(4), 4856–4866 (2015), doi:10.1364/OE.23.004856.

Fields§

§iterations: usize

Number of complete passes through the acquisition schedule.

§object_step: f64

Step size of the pupil-power-preconditioned object update.

§batch_size: usize

Number of frame gradients averaged into one update.

§epsilon: f64

Positive numerical floor used by losses and preconditioners.

§loss_type: LossType

Data-fidelity objective to differentiate and report.

§recover_illumination: bool

Whether to estimate a Fourier-grid offset for every illumination source.

§illumination_step: f64

Step size of the diagonally scaled illumination-offset update.

§illumination_finite_difference: f64

Central finite-difference spacing in Fourier-grid pixels.

§maximum_illumination_correction: f64

Maximum absolute row or column correction, in Fourier-grid pixels.

§recover_pupil: bool

Whether to update the complex pupil alongside the object.

§pupil_step: f64

Step size of the normalized pupil update.

§constrain_pupil_support: bool

Whether to zero recovered pupil values outside the compiled aperture.

§object_tv_weight: f64

Weight of the isotropic total-variation step on the complex object; 0 disables it.

§object_tv_epsilon: f64

Positive smoothing constant in the differentiable TV norm.

§pupil_smoothing_weight: f64

Weight of quadratic nearest-neighbor pupil smoothing; 0 disables it and positive values require pupil recovery.

§parallel_workers: usize

Maximum number of frame-gradient worker threads.

Implementations§

Source§

impl GradientDescent

Source

pub fn iterations(self, iterations: usize) -> Self

Source

pub fn object_step(self, step: f64) -> Self

Source

pub fn batch_size(self, batch_size: usize) -> Self

Source

pub fn loss_type(self, loss_type: LossType) -> Self

Source

pub fn recover_illumination(self, recover: bool) -> Self

Source

pub fn illumination_step(self, step: f64) -> Self

Source

pub fn illumination_finite_difference(self, distance: f64) -> Self

Source

pub fn illumination_bounds(self, maximum_absolute_correction: f64) -> Self

Source

pub fn recover_pupil(self, recover: bool) -> Self

Source

pub fn pupil_step(self, step: f64) -> Self

Source

pub fn constrain_pupil_support(self, constrain: bool) -> Self

Source

pub fn object_tv(self, weight: f64) -> Self

Source

pub fn object_tv_epsilon(self, epsilon: f64) -> Self

Source

pub fn pupil_smoothing(self, weight: f64) -> Self

Source

pub fn parallel_workers(self, workers: usize) -> Self

Sets the maximum number of frame-gradient workers. Object, pupil, and illumination-calibration contributions are reduced deterministically.

Trait Implementations§

Source§

impl Clone for GradientDescent

Source§

fn clone(&self) -> GradientDescent

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 Debug for GradientDescent

Source§

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

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

impl Default for GradientDescent

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl ReconstructionAlgorithm for GradientDescent

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,