@hackage numeric-optimization-backprop0.1.0.1
Wrapper of numeric-optimization package for using with backprop package
Categories
License
BSD-3-Clause
Maintainer
masahiro.sakai@gmail.com
Links
Versions
Installation
Tested Compilers
Dependencies (10)
- backprop >=0.2.6.3 && <0.3
- base >=4.12 && <5
- containers >=0.6.0.1 && <0.7
- data-default-class >=0.1.2.0 && <0.2
- mono-traversable >=1.0.15.1 && <1.1
- mtl >=2.2.2 && <2.4 Show all…
Dependents (0)
Package Flags
build-examples
(off by default)
Build example programs
numeric-optimization-backprop
Wrapper of numeric-optimization package for using with backprop package.
Example Usage
{-# LANGUAGE FlexibleContexts #-}
import Numeric.Optimization.Backprop
import Lens.Micro
main :: IO ()
main = do
result <- minimize LBFGS def rosenbrock Nothing [] (-3,-4)
print (resultSuccess result) -- True
print (resultSolution result) -- [0.999999999009131,0.9999999981094296]
print (resultValue result) -- 1.8129771632403013e-18
-- https://en.wikipedia.org/wiki/Rosenbrock_function
rosenbrock :: Reifies s W => BVar s (Double, Double) -> BVar s Double
rosenbrock t = sq (1 - x) + 100 * sq (y - sq x)
where
x = t ^^. _1
y = t ^^. _2
sq :: Floating a => a -> a
sq x = x ** 2