packages feed

ad 3.2 → 3.2.1

raw patch · 3 files changed

+7/−5 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.markdown view
@@ -1,3 +1,7 @@+3.2.1+---+* `conjugateGradientDescent` now stops before it starts returning NaN results.+ 3.2 --- * Renamed `Chain` to `Wengert` to reflect its use of Wengert lists for reverse mode.
ad.cabal view
@@ -1,5 +1,5 @@ name:         ad-version:      3.2+version:      3.2.1 license:      BSD3 license-File: LICENSE copyright:    (c) Edward Kmett 2010-2012,
src/Numeric/AD/Newton.hs view
@@ -121,9 +121,8 @@ {-# INLINE gradientAscent #-}  -- | Perform a conjugate gradient descent using reverse mode automatic differentiation to compute the gradient.-conjugateGradientDescent :: (Traversable f, Fractional a, Ord a) =>-                (forall s. Mode s => f (AD s a) -> AD s a) -> f a -> [f a]-conjugateGradientDescent f x0 = go x0 d0 d0+conjugateGradientDescent :: (Traversable f, Fractional a, Ord a) => (forall s. Mode s => f (AD s a) -> AD s a) -> f a -> [f a]+conjugateGradientDescent f x0 = takeWhile (all (\a -> a == a)) (go x0 d0 d0)   where     dot x y = sum $ zipWithT (*) x y     d0 = negate <$> grad f x0@@ -133,7 +132,6 @@         xi1 = zipWithT (\x d -> x + ai*d) xi di         ri1 = negate <$> grad f xi1         bi1 = max 0 $ dot ri1 (zipWithT (-) ri1 ri) / dot ri1 ri1-        -- bi1 = max 0 $ sum (zipWithT (\a b -> a * (a - b)) ri1 ri) / dot ri1 ri1         di1 = zipWithT (\r d -> r * bi1*d) ri1 di {-# INLINE conjugateGradientDescent #-}