Copyright | (c) Fabricio Olivetti 2021 - 2024 |
---|---|
License | BSD3 |
Maintainer | fabricio.olivetti@gmail.com |
Stability | experimental |
Portability | FlexibleInstances, DeriveFunctor, ScopedTypeVariables |
Safe Haskell | None |
Language | Haskell2010 |
Automatic Differentiation for Expression trees
Synopsis
- forwardMode :: Array S Ix2 Double -> Array S Ix1 Double -> SRVector -> Fix SRTree -> (Array D Ix1 Double, Array S Ix1 Double)
- forwardModeUnique :: SRMatrix -> PVector -> SRVector -> Fix SRTree -> (SRVector, Array S Ix1 Double)
- reverseModeUnique :: SRMatrix -> PVector -> SRVector -> (SRVector -> SRVector) -> Fix SRTree -> (Array D Ix1 Double, Array S Ix1 Double)
- reverseModeUniqueArr :: (Num a, Eq a, Manifest r1 Double, Manifest r2 Double, Source r3 Double) => Array r1 Ix2 Double -> Array r2 Int Double -> Array r3 Ix1 Double -> (Array D Ix1 Double -> Array D Ix1 Double) -> [(Key, (a, Int, Int, Double))] -> IntMap Int -> (Array D Ix1 Double, Array S Int Double)
- forwardModeUniqueJac :: SRMatrix -> PVector -> Fix SRTree -> [PVector]
Documentation
forwardMode :: Array S Ix2 Double -> Array S Ix1 Double -> SRVector -> Fix SRTree -> (Array D Ix1 Double, Array S Ix1 Double) Source #
Calculates the results of the error vector multiplied by the Jacobian of an expression using forward mode
provided a vector of variable values xss
, a vector of parameter values theta
and
a function that changes a Double value to the type of the variable values.
uses unsafe operations to use mutable array instead of a tape
forwardModeUnique :: SRMatrix -> PVector -> SRVector -> Fix SRTree -> (SRVector, Array S Ix1 Double) Source #
The function forwardModeUnique
calculates the numerical gradient of the tree and evaluates the tree at the same time. It assumes that each parameter has a unique occurrence in the expression. This should be significantly faster than forwardMode
.
reverseModeUnique :: SRMatrix -> PVector -> SRVector -> (SRVector -> SRVector) -> Fix SRTree -> (Array D Ix1 Double, Array S Ix1 Double) Source #
Same as above, but using reverse mode, that is even faster.
reverseModeUniqueArr :: (Num a, Eq a, Manifest r1 Double, Manifest r2 Double, Source r3 Double) => Array r1 Ix2 Double -> Array r2 Int Double -> Array r3 Ix1 Double -> (Array D Ix1 Double -> Array D Ix1 Double) -> [(Key, (a, Int, Int, Double))] -> IntMap Int -> (Array D Ix1 Double, Array S Int Double) Source #
Same as above, but using reverse mode with the tree encoded as an array, that is even faster. reverseModeUniqueArr :: SRMatrix -> PVector -> SRVector -> (SRVector -> SRVector) -> Array S Ix1 (Int, Int, Int, Double) -- arity, opcode, ix, const val -> (Array D Ix1 Double, Array S Ix1 Double)
forwardModeUniqueJac :: SRMatrix -> PVector -> Fix SRTree -> [PVector] Source #
The function forwardModeUnique
calculates the numerical gradient of the tree and evaluates the tree at the same time. It assumes that each parameter has a unique occurrence in the expression. This should be significantly faster than forwardMode
.