Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides a category transformer for automatic differentiation.
There are many alternative notions of a generalized derivative. Perhaps the most common is the differential Ring. In Haskell, this might be defined as:
class Field r => Differential r where derivative :: r -> r type Diff cat = forall a b. (Category cat, Differential cat a b)
But this runs into problems with the lack of polymorphic constraints in GHC. See, for example GHC ticket #2893.
References:
- data Forward a = Forward {}
- proveC1 :: (a ~ (a >< a), Rig a) => (Forward a -> Forward a) -> C1 (a -> a)
- proveC2 :: (a ~ (a >< a), Rig a) => (Forward (Forward a) -> Forward (Forward a)) -> C2 (a -> a)
- class C cat where
- type D cat :: * -> * -> *
- derivative :: cat a b -> D cat a (a >< b)
- data Diff n a b where
- unsafeProveC0 :: (a -> b) -> Diff 0 a b
- unsafeProveC1 :: (a -> b) -> (a -> a >< b) -> C1 (a -> b)
- unsafeProveC2 :: (a -> b) -> (a -> a >< b) -> (a -> a >< (a >< b)) -> C2 (a -> b)
- type C0 a = C0_ a
- type family C0_ f :: *
- type C1 a = C1_ a
- type family C1_ f :: *
- type C2 a = C2_ a
- type family C2_ f :: *
Documentation
This is essentially just a translation of the Numeric.AD.Forward.Forward type for use with the SubHask numeric hierarchy.
FIXME:
Add reverse mode auto-differentiation for vectors. Apply the ProofOf framework from Monotonic
Show a => Show (Forward a) Source | |
IsMutable (Forward a) Source | |
Field a => Field (Forward a) Source | |
Ring a => Ring (Forward a) Source | |
Rig a => Rig (Forward a) Source | |
Rg a => Rg (Forward a) Source | |
Abelian a => Abelian (Forward a) Source | |
Group a => Group (Forward a) Source | |
Cancellative a => Cancellative (Forward a) Source | |
Monoid a => Monoid (Forward a) Source | |
Semigroup a => Semigroup (Forward a) Source | |
data Mutable m (Forward a0) = Mutable_AppT__ConT_SubHask_Category_Trans_Derivative_Forward___VarT_a_1628002786_ (PrimRef m (Forward a)) Source |
proveC2 :: (a ~ (a >< a), Rig a) => (Forward (Forward a) -> Forward (Forward a)) -> C2 (a -> a) Source
derivative :: cat a b -> D cat a (a >< b) Source
unsafeProveC0 :: (a -> b) -> Diff 0 a b Source