circuits-learn
Safe HaskellNone
LanguageGHC2024

Circuit.Learn.Adam

Synopsis

EWMA building block

ewma :: Double -> Double -> Process Double Double Source #

Exponentially weighted moving average as a Process.

State is the current EWMA value; output is the same value.

ewmaDirect :: Double -> Double -> [Double] -> [Double] Source #

Direct EWMA recurrence on a list (no Process overhead). First element is after first observation.

Adam

adam :: Double -> Double -> Double -> Double -> Process Double Double Source #

Adam parameter update as a Process.

Input: gradient. Output: parameter update (not the new parameter). State: (m, v, t) — first moment, second moment, timestep.

adamDecomposed :: Double -> Double -> Double -> Double -> [Double] -> [Double] Source #

Adam decomposed into two independent EWMA channels (the frontier claim).

The m channel is an EWMA of raw gradients (beta1-weighted), the v channel is an EWMA of squared gradients (beta2-weighted). Each is computed independently via scanl', then combined with the bias-corrected quotient. This produces exactly the same updates as the monolithic adam Process.

adamReference :: Double -> Double -> Double -> [Double] -> [(Double, Double, Int)] Source #

Reference Adam state recurrence on a gradient trace.

Forward recurrence starting from (0, 0, 0); the first element corresponds to the state after observing g0.

adamUpdates :: Double -> Double -> Double -> Double -> [(Double, Double, Int)] -> [Double] Source #

Convert reference states to Adam parameter updates.

This applies the same bias-correction and scaling as adam so the two can be compared directly on a fixed trace.