tensor-ops-0.1.0.0: Tensor manipulation operations with tensorflow-style automatic differentiation

Safe HaskellNone
LanguageHaskell2010

TensorOps.Learn.NeuralNet.Recurrent

Synopsis

Documentation

data Network :: ([k] -> Type) -> k -> k -> Type Source #

Instances

Category k (Network k t) Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

NFData1 [k] t => NFData (Network k t i o) Source # 

Methods

rnf :: Network k t i o -> () #

buildNet Source #

Arguments

:: (SingI ss, SingI ps) 
=> TOp ('[i] ': (ss ++ ps)) ('[o] ': ss)

Tensor operation for network

-> Prod t ss

Initial states

-> Prod t ps

Network parameters

-> Network t i o 

netParams :: Network t i o -> (forall ss ps. (SingI ss, SingI ps) => Prod t ss -> Prod t ps -> r) -> r Source #

runNetwork :: (RealFloat (ElemT t), Tensor t) => Network t i o -> t '[i] -> (t '[o], Network t i o) Source #

runNetworkSt :: (RealFloat (ElemT t), Tensor t, MonadState (Network t i o) m) => t '[i] -> m (t '[o]) Source #

genNet :: forall k o i m t. (SingI o, SingI i, PrimMonad m, Tensor t) => [(Integer, (Activation k, Maybe (Activation k)))] -> Activation k -> Maybe (Activation k) -> Gen (PrimState m) -> m (Network t i o) Source #

fullyConnected Source #

Arguments

:: forall (i :: k) (o :: k) (m :: Type -> Type) (t :: [k] -> Type). (SingI i, SingI o, PrimMonad m, Tensor t) 
=> Activation k

Activation function for internal state

-> Gen (PrimState m) 
-> m (Network t i o) 

ffLayer :: forall i o m t. (SingI i, SingI o, PrimMonad m, Tensor t) => Gen (PrimState m) -> m (Network t i o) Source #

stateless :: Network t i o -> Network t i o Source #

Convert a neural network from TensorOps.Learn.NeuralNet.FeedForward to a stateless Network.

Can be thought a functor from the category of stateless neural networks to the category of stateful (recurrent) ones.

(~*~) :: forall k t a b c. Network t a b -> Network t b c -> Network t a c infixr 4 Source #

(*~) :: Network t a b -> TOp '['[b]] '['[c]] -> Network t a c infixl 5 Source #

(~*) :: TOp '['[a]] '['[b]] -> Network t b c -> Network t a c infixr 4 Source #

nmap :: SingI o => (forall a. RealFloat a => a -> a) -> Network t i o -> Network t i o Source #

trainNetwork Source #

Arguments

:: forall (t :: [k] -> Type) (i :: k) (o :: k). (Tensor t, RealFloat (ElemT t), SingI i, SingI o) 
=> TOp '['[o], '[o]] '['[]]

loss function (input, target)

-> ElemT t

train rate for initial state

-> ElemT t

train rate for network parameters

-> [(t '[i], t '[o])]

inputs and targets

-> Network t i o 
-> Network t i o 

trainNetwork' Source #

Arguments

:: forall (t :: [k] -> Type) (i :: k) (o :: k). (Tensor t, RealFloat (ElemT t), SingI i, SingI o) 
=> TOp '['[o], '[o]] '['[]]

loss function (input, target)

-> ElemT t

train rate for initial state

-> ElemT t

train rate for network parameters

-> Vec n (t '[i])

inputs

-> Vec n (t '[o])

targets

-> Network t i o 
-> Network t i o 

networkGradient Source #

Arguments

:: forall (t :: [k] -> Type) (i :: k) (o :: k). (Tensor t, RealFloat (ElemT t), SingI i, SingI o) 
=> TOp '['[o], '[o]] '['[]]

loss function (output, target)

-> Vec n (t '[i])

inputs

-> Vec n (t '[o])

targets

-> Network t i o 
-> (forall ss ps. (SingI ss, SingI ps) => Vec n (t '[i]) -> Prod t ss -> Prod t ps -> r) 
-> r