backprop-learn-0.1.0.0: Combinators and useful tools for ANNs using the backprop library

Safe HaskellNone
LanguageHaskell2010

Backprop.Learn.Model

Contents

Synopsis

Documentation

class Backprop a where #

Class of values that can be backpropagated in general.

For instances of Num, these methods can be given by zeroNum, addNum, and oneNum. There are also generic options given in Numeric.Backprop.Class for functors, IsList instances, and Generic instances.

instance Backprop Double where
    zero = zeroNum
    add = addNum
    one = oneNum

If you leave the body of an instance declaration blank, GHC Generics will be used to derive instances if the type has a single constructor and each field is an instance of Backprop.

To ensure that backpropagation works in a sound way, should obey the laws:

identity

Also implies preservation of information, making zipWith (+) an illegal implementation for lists and vectors.

This is only expected to be true up to potential "extra zeroes" in x and y in the result.

commutativity
associativity
idempotence
unital

Note that not all values in the backpropagation process needs all of these methods: Only the "final result" needs one, for example. These are all grouped under one typeclass for convenience in defining instances, and also to talk about sensible laws. For fine-grained control, use the "explicit" versions of library functions (for example, in Numeric.Backprop.Explicit) instead of Backprop based ones.

This typeclass replaces the reliance on Num of the previous API (v0.1). Num is strictly more powerful than Backprop, and is a stronger constraint on types than is necessary for proper backpropagating. In particular, fromInteger is a problem for many types, preventing useful backpropagation for lists, variable-length vectors (like Data.Vector) and variable-size matrices from linear algebra libraries like hmatrix and accelerate.

Since: backprop-0.2.0.0

Minimal complete definition

Nothing

Methods

zero :: a -> a #

"Zero out" all components of a value. For scalar values, this should just be const 0. For vectors and matrices, this should set all components to zero, the additive identity.

Should be idempotent:

Should be as lazy as possible. This behavior is observed for all instances provided by this library.

See zeroNum for a pre-built definition for instances of Num and zeroFunctor for a definition for instances of Functor. If left blank, will automatically be genericZero, a pre-built definition for instances of Generic whose fields are all themselves instances of Backprop.

add :: a -> a -> a #

Add together two values of a type. To combine contributions of gradients, so should be information-preserving:

Should be as strict as possible. This behavior is observed for all instances provided by this library.

See addNum for a pre-built definition for instances of Num and addIsList for a definition for instances of IsList. If left blank, will automatically be genericAdd, a pre-built definition for instances of Generic with one constructor whose fields are all themselves instances of Backprop.

one :: a -> a #

One all components of a value. For scalar values, this should just be const 1. For vectors and matrices, this should set all components to one, the multiplicative identity.

As the library uses it, the most important law is:

That is, one x is the gradient of the identity function with respect to its input.

Ideally should be idempotent:

Should be as lazy as possible. This behavior is observed for all instances provided by this library.

See oneNum for a pre-built definition for instances of Num and oneFunctor for a definition for instances of Functor. If left blank, will automatically be genericOne, a pre-built definition for instances of Generic whose fields are all themselves instances of Backprop.

Instances
Backprop Double 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Double -> Double #

add :: Double -> Double -> Double #

one :: Double -> Double #

Backprop Float 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Float -> Float #

add :: Float -> Float -> Float #

one :: Float -> Float #

Backprop Int 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Int -> Int #

add :: Int -> Int -> Int #

one :: Int -> Int #

Backprop Integer 
Instance details

Defined in Numeric.Backprop.Class

Backprop Natural

Since: backprop-0.2.1.0

Instance details

Defined in Numeric.Backprop.Class

Backprop Word

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Word -> Word #

add :: Word -> Word -> Word #

one :: Word -> Word #

Backprop Word8

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Word8 -> Word8 #

add :: Word8 -> Word8 -> Word8 #

one :: Word8 -> Word8 #

Backprop Word16

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Word16 -> Word16 #

add :: Word16 -> Word16 -> Word16 #

one :: Word16 -> Word16 #

Backprop Word32

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Word32 -> Word32 #

add :: Word32 -> Word32 -> Word32 #

one :: Word32 -> Word32 #

Backprop Word64

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Word64 -> Word64 #

add :: Word64 -> Word64 -> Word64 #

one :: Word64 -> Word64 #

Backprop ()

add is strict, but zero and one are lazy in their arguments.

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: () -> () #

add :: () -> () -> () #

one :: () -> () #

Backprop Void 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Void -> Void #

add :: Void -> Void -> Void #

one :: Void -> Void #

Backprop a => Backprop [a]

add assumes the shorter list has trailing zeroes, and the result has the length of the longest input.

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: [a] -> [a] #

add :: [a] -> [a] -> [a] #

one :: [a] -> [a] #

Backprop a => Backprop (Maybe a)

Nothing is treated the same as Just 0. However, zero, add, and one preserve Nothing if all inputs are also Nothing.

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Maybe a -> Maybe a #

add :: Maybe a -> Maybe a -> Maybe a #

one :: Maybe a -> Maybe a #

Integral a => Backprop (Ratio a) 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Ratio a -> Ratio a #

add :: Ratio a -> Ratio a -> Ratio a #

one :: Ratio a -> Ratio a #

Num a => Backprop (NumBP a) 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: NumBP a -> NumBP a #

add :: NumBP a -> NumBP a -> NumBP a #

one :: NumBP a -> NumBP a #

RealFloat a => Backprop (Complex a) 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Complex a -> Complex a #

add :: Complex a -> Complex a -> Complex a #

one :: Complex a -> Complex a #

Backprop a => Backprop (First a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: First a -> First a #

add :: First a -> First a -> First a #

one :: First a -> First a #

Backprop a => Backprop (Last a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Last a -> Last a #

add :: Last a -> Last a -> Last a #

one :: Last a -> Last a #

Backprop a => Backprop (Option a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Option a -> Option a #

add :: Option a -> Option a -> Option a #

one :: Option a -> Option a #

Backprop a => Backprop (Identity a) 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Identity a -> Identity a #

add :: Identity a -> Identity a -> Identity a #

one :: Identity a -> Identity a #

Backprop a => Backprop (First a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: First a -> First a #

add :: First a -> First a -> First a #

one :: First a -> First a #

Backprop a => Backprop (Last a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Last a -> Last a #

add :: Last a -> Last a -> Last a #

one :: Last a -> Last a #

Backprop a => Backprop (Dual a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Dual a -> Dual a #

add :: Dual a -> Dual a -> Dual a #

one :: Dual a -> Dual a #

Backprop a => Backprop (Sum a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Sum a -> Sum a #

add :: Sum a -> Sum a -> Sum a #

one :: Sum a -> Sum a #

Backprop a => Backprop (Product a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Product a -> Product a #

add :: Product a -> Product a -> Product a #

one :: Product a -> Product a #

Backprop a => Backprop (NonEmpty a)

add assumes the shorter list has trailing zeroes, and the result has the length of the longest input.

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: NonEmpty a -> NonEmpty a #

add :: NonEmpty a -> NonEmpty a -> NonEmpty a #

one :: NonEmpty a -> NonEmpty a #

Backprop a => Backprop (IntMap a)

zero and one replace all current values, and add merges keys from both maps, adding in the case of double-occurrences.

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: IntMap a -> IntMap a #

add :: IntMap a -> IntMap a -> IntMap a #

one :: IntMap a -> IntMap a #

Backprop a => Backprop (Seq a)

add assumes the shorter sequence has trailing zeroes, and the result has the length of the longest input.

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Seq a -> Seq a #

add :: Seq a -> Seq a -> Seq a #

one :: Seq a -> Seq a #

(Storable a, Backprop a) => Backprop (Vector a) 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Vector a -> Vector a #

add :: Vector a -> Vector a -> Vector a #

one :: Vector a -> Vector a #

(Unbox a, Backprop a) => Backprop (Vector a) 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Vector a -> Vector a #

add :: Vector a -> Vector a -> Vector a #

one :: Vector a -> Vector a #

(Prim a, Backprop a) => Backprop (Vector a) 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Vector a -> Vector a #

add :: Vector a -> Vector a -> Vector a #

one :: Vector a -> Vector a #

Backprop a => Backprop (Vector a) 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Vector a -> Vector a #

add :: Vector a -> Vector a -> Vector a #

one :: Vector a -> Vector a #

Backprop (Label field)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Label field -> Label field #

add :: Label field -> Label field -> Label field #

one :: Label field -> Label field #

Backprop a => Backprop (Identity a)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Identity a -> Identity a #

add :: Identity a -> Identity a -> Identity a #

one :: Identity a -> Identity a #

Backprop a => Backprop (Thunk a)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Thunk a -> Thunk a #

add :: Thunk a -> Thunk a -> Thunk a #

one :: Thunk a -> Thunk a #

Backprop t => Backprop (ElField ((,) s t))

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: ElField (s, t) -> ElField (s, t) #

add :: ElField (s, t) -> ElField (s, t) -> ElField (s, t) #

one :: ElField (s, t) -> ElField (s, t) #

PureProdC Maybe Backprop as => Backprop (TMaybe as) Source # 
Instance details

Defined in Data.Type.Tuple

Methods

zero :: TMaybe as -> TMaybe as #

add :: TMaybe as -> TMaybe as -> TMaybe as #

one :: TMaybe as -> TMaybe as #

Backprop a => Backprop (TF a) Source # 
Instance details

Defined in Data.Type.Tuple

Methods

zero :: TF a -> TF a #

add :: TF a -> TF a -> TF a #

one :: TF a -> TF a #

Backprop a => Backprop (NoRegularize a) Source # 
Instance details

Defined in Backprop.Learn.Regularize

Backprop a => Backprop (RegularizeMetric a) Source # 
Instance details

Defined in Backprop.Learn.Regularize

Backprop a => Backprop (r -> a)

add adds together results; zero and one act on results.

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: (r -> a) -> r -> a #

add :: (r -> a) -> (r -> a) -> r -> a #

one :: (r -> a) -> r -> a #

Backprop (V1 p)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: V1 p -> V1 p #

add :: V1 p -> V1 p -> V1 p #

one :: V1 p -> V1 p #

Backprop (U1 p)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: U1 p -> U1 p #

add :: U1 p -> U1 p -> U1 p #

one :: U1 p -> U1 p #

(Backprop a, Backprop b) => Backprop (a, b)

add is strict

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: (a, b) -> (a, b) #

add :: (a, b) -> (a, b) -> (a, b) #

one :: (a, b) -> (a, b) #

(Backprop a, Ord k) => Backprop (Map k a)

zero and one replace all current values, and add merges keys from both maps, adding in the case of double-occurrences.

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Map k a -> Map k a #

add :: Map k a -> Map k a -> Map k a #

one :: Map k a -> Map k a #

(Backprop a, Reifies s W) => Backprop (BVar s a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Internal

Methods

zero :: BVar s a -> BVar s a #

add :: BVar s a -> BVar s a -> BVar s a #

one :: BVar s a -> BVar s a #

(Vector v a, Num a) => Backprop (NumVec v a) 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: NumVec v a -> NumVec v a #

add :: NumVec v a -> NumVec v a -> NumVec v a #

one :: NumVec v a -> NumVec v a #

(Applicative f, Backprop a) => Backprop (ABP f a) 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: ABP f a -> ABP f a #

add :: ABP f a -> ABP f a -> ABP f a #

one :: ABP f a -> ABP f a #

(Backprop a, Backprop b) => Backprop (Arg a b)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Arg a b -> Arg a b #

add :: Arg a b -> Arg a b -> Arg a b #

one :: Arg a b -> Arg a b #

Backprop (Proxy a) 
Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Proxy a -> Proxy a #

add :: Proxy a -> Proxy a -> Proxy a #

one :: Proxy a -> Proxy a #

Backprop (SField field)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: SField field -> SField field #

add :: SField field -> SField field -> SField field #

one :: SField field -> SField field #

(Backprop a, Backprop b) => Backprop (a :# b) Source # 
Instance details

Defined in Data.Type.Tuple

Methods

zero :: (a :# b) -> a :# b #

add :: (a :# b) -> (a :# b) -> a :# b #

one :: (a :# b) -> a :# b #

(KnownNat o, KnownNat i) => Backprop (LRp i o) Source # 
Instance details

Defined in Backprop.Learn.Model.Regression

Methods

zero :: LRp i o -> LRp i o #

add :: LRp i o -> LRp i o -> LRp i o #

one :: LRp i o -> LRp i o #

Backprop (ARIMAp a b) Source # 
Instance details

Defined in Backprop.Learn.Model.Regression

Methods

zero :: ARIMAp a b -> ARIMAp a b #

add :: ARIMAp a b -> ARIMAp a b -> ARIMAp a b #

one :: ARIMAp a b -> ARIMAp a b #

KnownNat o => Backprop (LSTMp i o) Source # 
Instance details

Defined in Backprop.Learn.Model.Neural.LSTM

Methods

zero :: LSTMp i o -> LSTMp i o #

add :: LSTMp i o -> LSTMp i o -> LSTMp i o #

one :: LSTMp i o -> LSTMp i o #

KnownNat o => Backprop (GRUp i o) Source # 
Instance details

Defined in Backprop.Learn.Model.Neural.LSTM

Methods

zero :: GRUp i o -> GRUp i o #

add :: GRUp i o -> GRUp i o -> GRUp i o #

one :: GRUp i o -> GRUp i o #

(Backprop a, Backprop b, Backprop c) => Backprop (a, b, c)

add is strict

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: (a, b, c) -> (a, b, c) #

add :: (a, b, c) -> (a, b, c) -> (a, b, c) #

one :: (a, b, c) -> (a, b, c) #

(ReifyConstraint Backprop f rs, RMap rs, RApply rs) => Backprop (Rec f rs)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Rec f rs -> Rec f rs #

add :: Rec f rs -> Rec f rs -> Rec f rs #

one :: Rec f rs -> Rec f rs #

(Backprop a, Applicative m) => Backprop (Kleisli m r a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Kleisli m r a -> Kleisli m r a #

add :: Kleisli m r a -> Kleisli m r a -> Kleisli m r a #

one :: Kleisli m r a -> Kleisli m r a #

Backprop w => Backprop (Const w a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Const w a -> Const w a #

add :: Const w a -> Const w a -> Const w a #

one :: Const w a -> Const w a #

(ReifyConstraint Backprop f rs, RMap rs, RApply rs, IsoXRec f rs) => Backprop (XRec f rs)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: XRec f rs -> XRec f rs #

add :: XRec f rs -> XRec f rs -> XRec f rs #

one :: XRec f rs -> XRec f rs #

Backprop (HKD t a) => Backprop (XData t a)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: XData t a -> XData t a #

add :: XData t a -> XData t a -> XData t a #

one :: XData t a -> XData t a #

(ReifyConstraint Backprop f rs, RMap rs, RApply rs, RecApplicative rs, NatToInt (RLength rs), RPureConstrained (IndexableField rs) rs) => Backprop (ARec f rs)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: ARec f rs -> ARec f rs #

add :: ARec f rs -> ARec f rs -> ARec f rs #

one :: ARec f rs -> ARec f rs #

(ReifyConstraint Backprop f rs, RMap rs, RApply rs, Storable (Rec f rs)) => Backprop (SRec f rs)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: SRec f rs -> SRec f rs #

add :: SRec f rs -> SRec f rs -> SRec f rs #

one :: SRec f rs -> SRec f rs #

Backprop w => Backprop (Const w a)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Const w a -> Const w a #

add :: Const w a -> Const w a -> Const w a #

one :: Const w a -> Const w a #

Backprop (ARIMAs a b c) Source # 
Instance details

Defined in Backprop.Learn.Model.Regression

Methods

zero :: ARIMAs a b c -> ARIMAs a b c #

add :: ARIMAs a b c -> ARIMAs a b c -> ARIMAs a b c #

one :: ARIMAs a b c -> ARIMAs a b c #

Backprop a => Backprop (K1 i a p)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: K1 i a p -> K1 i a p #

add :: K1 i a p -> K1 i a p -> K1 i a p #

one :: K1 i a p -> K1 i a p #

(Backprop (f p), Backprop (g p)) => Backprop ((f :*: g) p)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: (f :*: g) p -> (f :*: g) p #

add :: (f :*: g) p -> (f :*: g) p -> (f :*: g) p #

one :: (f :*: g) p -> (f :*: g) p #

(Backprop a, Backprop b, Backprop c, Backprop d) => Backprop (a, b, c, d)

add is strict

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: (a, b, c, d) -> (a, b, c, d) #

add :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) #

one :: (a, b, c, d) -> (a, b, c, d) #

(Backprop (f a), Backprop (g a)) => Backprop (Product f g a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Product f g a -> Product f g a #

add :: Product f g a -> Product f g a -> Product f g a #

one :: Product f g a -> Product f g a #

Backprop (f p) => Backprop (M1 i c f p)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: M1 i c f p -> M1 i c f p #

add :: M1 i c f p -> M1 i c f p -> M1 i c f p #

one :: M1 i c f p -> M1 i c f p #

Backprop (f (g a)) => Backprop ((f :.: g) a)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: (f :.: g) a -> (f :.: g) a #

add :: (f :.: g) a -> (f :.: g) a -> (f :.: g) a #

one :: (f :.: g) a -> (f :.: g) a #

(Backprop a, Backprop b, Backprop c, Backprop d, Backprop e) => Backprop (a, b, c, d, e)

add is strict

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: (a, b, c, d, e) -> (a, b, c, d, e) #

add :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) #

one :: (a, b, c, d, e) -> (a, b, c, d, e) #

Backprop (f (g a)) => Backprop (Compose f g a)

Since: backprop-0.2.2.0

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Compose f g a -> Compose f g a #

add :: Compose f g a -> Compose f g a -> Compose f g a #

one :: Compose f g a -> Compose f g a #

Backprop (f (g a)) => Backprop (Compose f g a)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Compose f g a -> Compose f g a #

add :: Compose f g a -> Compose f g a -> Compose f g a #

one :: Compose f g a -> Compose f g a #

Backprop (op (f a) (g a)) => Backprop (Lift op f g a)

Since: backprop-0.2.6.3

Instance details

Defined in Numeric.Backprop.Class

Methods

zero :: Lift op f g a -> Lift op f g a #

add :: Lift op f g a -> Lift op f g a -> Lift op f g a #

one :: Lift op f g a -> Lift op f g a #

Running and Grad

runModel :: forall p s a b. (AllConstrainedProd Backprop s, Backprop b) => Model p s a b -> TMaybe p -> a -> TMaybe s -> (b, TMaybe s) Source #

runModelStoch :: forall p s a b m. (AllConstrainedProd Backprop s, Backprop b, PrimMonad m) => Model p s a b -> Gen (PrimState m) -> TMaybe p -> a -> TMaybe s -> m (b, TMaybe s) Source #

runModelStateless :: Model p Nothing a b -> TMaybe p -> a -> b Source #

runModelStochStateless :: PrimMonad m => Model p Nothing a b -> Gen (PrimState m) -> TMaybe p -> a -> m b Source #

Work with parameters

initParam Source #

Arguments

:: (Initialize p, ContGen d, PrimMonad m) 
=> model (Just p) s a b

ignored

-> d 
-> Gen (PrimState m) 
-> m p 

initParamNormal Source #

Arguments

:: (Initialize p, PrimMonad m) 
=> model (Just p) s a b

ignored

-> Double 
-> Gen (PrimState m) 
-> m p 

encodeParam Source #

Arguments

:: Binary p 
=> model (Just p) s a b

ignored

-> p 
-> ByteString 

decodeParam Source #

Arguments

:: Binary p 
=> model (Just p) s a b

ignored

-> ByteString 
-> p 

decodeParamOrFail Source #

Arguments

:: Binary p 
=> model (Just p) s a b

ignored

-> ByteString 
-> Either String p 

saveParam Source #

Arguments

:: Binary p 
=> model (Just p) s a b

ignored

-> FilePath 
-> p 
-> IO () 

loadParam Source #

Arguments

:: Binary p 
=> model (Just p) s a b

ignored

-> FilePath 
-> IO p 

loadParamOrFail Source #

Arguments

:: Binary p 
=> model (Just p) s a b

ignored

-> FilePath 
-> IO (Either String p) 

Iterated runners

iterateModel Source #

Arguments

:: (Backprop b, AllConstrainedProd Backprop s) 
=> (b -> a)

loop

-> Int

num times

-> Model p s a b 
-> TMaybe p 
-> a 
-> TMaybe s 
-> ([b], TMaybe s) 

iterateModelM Source #

Arguments

:: (Backprop b, AllConstrainedProd Backprop s, Monad m) 
=> (b -> m a)

loop

-> Int

num times

-> Model p s a b 
-> TMaybe p 
-> a 
-> TMaybe s 
-> m ([b], TMaybe s) 

iterateModelStoch Source #

Arguments

:: (Backprop b, AllConstrainedProd Backprop s, PrimMonad m) 
=> (b -> m a)

loop

-> Int

num times

-> Model p s a b 
-> Gen (PrimState m) 
-> TMaybe p 
-> a 
-> TMaybe s 
-> m ([b], TMaybe s) 

scanModel :: (Traversable t, Backprop b, AllConstrainedProd Backprop s) => Model p s a b -> TMaybe p -> t a -> TMaybe s -> (t b, TMaybe s) Source #

scanModelStoch :: (Traversable t, Backprop b, AllConstrainedProd Backprop s, PrimMonad m) => Model p s a b -> Gen (PrimState m) -> TMaybe p -> t a -> TMaybe s -> m (t b, TMaybe s) Source #

No final state

iterateModel_ Source #

Arguments

:: (Backprop b, AllConstrainedProd Backprop s) 
=> (b -> a)

loop

-> Model p s a b 
-> TMaybe p 
-> a 
-> TMaybe s 
-> [b] 

iterateModelM_ Source #

Arguments

:: (Backprop b, AllConstrainedProd Backprop s, Monad m) 
=> (b -> m a)

loop

-> Int

num times

-> Model p s a b 
-> TMaybe p 
-> a 
-> TMaybe s 
-> m [b] 

iterateModelStoch_ Source #

Arguments

:: (Backprop b, AllConstrainedProd Backprop s, PrimMonad m) 
=> (b -> m a)

loop

-> Int

num times

-> Model p s a b 
-> Gen (PrimState m) 
-> TMaybe p 
-> a 
-> TMaybe s 
-> m [b] 

scanModel_ :: (Traversable t, Backprop b, AllConstrainedProd Backprop s) => Model p s a b -> TMaybe p -> t a -> TMaybe s -> t b Source #

scanModelStoch_ :: (Traversable t, Backprop b, AllConstrainedProd Backprop s, PrimMonad m) => Model p s a b -> Gen (PrimState m) -> TMaybe p -> t a -> TMaybe s -> m (t b) Source #

Prime runners

primeModel :: (Foldable t, Backprop b, AllConstrainedProd Backprop s) => Model p s a b -> TMaybe p -> t a -> TMaybe s -> TMaybe s Source #

primeModelStoch :: (Foldable t, Backprop b, AllConstrainedProd Backprop s, PrimMonad m) => Model p s a b -> Gen (PrimState m) -> TMaybe p -> t a -> TMaybe s -> m (TMaybe s) Source #

selfPrime Source #

Arguments

:: (Backprop b, AllConstrainedProd Backprop s) 
=> (b -> a)

loop

-> Model p s a b 
-> TMaybe p 
-> a 
-> TMaybe s 
-> [TMaybe s] 

selfPrimeM Source #

Arguments

:: (Backprop b, AllConstrainedProd Backprop s, Monad m) 
=> (b -> m a)

loop

-> Int

num times

-> Model p s a b 
-> TMaybe p 
-> a 
-> TMaybe s 
-> m (TMaybe s)