Copyright | (c) 2016 Jiasen Wu |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Jiasen Wu <jiasenwu@hotmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
This module defines an abstract interface for neural network and a protocol for its backends to follow.
- class Component a where
- learn :: (Component n, Monad (Run n)) => (Out n -> Out n -> Run n (Out n)) -> Float -> n -> (Inp n, Out n) -> Run n n
- relu :: (Num a, Ord a) => a -> a
- relu' :: (Num a, Ord a) => a -> a
- cost' :: (Num a, Ord a) => a -> a -> a
- class Backend b s where
- type Env b :: * -> *
- type ConvertFromSpec s :: *
- class (Monad r, Monad e) => RunInEnv r e where
- data a :++ b = a :++ b
- data SpecIn1D = In1D Int
- data SpecIn2D = In2D Int Int
- data SpecReshape2DAs1D = Reshape2DAs1D
- data SpecFullConnect = FullConnect Int
- data SpecConvolution = Convolution Int Int Int
- data SpecMaxPooling = MaxPooling Int
Documentation
class Component a where Source #
Abstraction of a neural network component
execution environment
the type of input and in-error
the type of output and out-error
the trace of a forward propagation
forwardT :: a -> Inp a -> Run a (Trace a) Source #
Forward propagation
forward :: Applicative (Run a) => a -> Inp a -> Run a (Out a) Source #
Forward propagation
output :: Trace a -> Out a Source #
extract the output value from the trace
backward :: a -> Trace a -> Out a -> Float -> Run a (a, Inp a) Source #
Backward propagation
:: (Component n, Monad (Run n)) | |
=> (Out n -> Out n -> Run n (Out n)) | derivative of the error function |
-> Float | learning rate |
-> n | neuron network |
-> (Inp n, Out n) | input and expect output |
-> Run n n | updated network |
By giving a way to measure the error, learn
can update the
neural network component.
class Backend b s where Source #
Abstraction of backend to carry out the specification
witness :: b -> s -> Dict (Monad (Env b), Monad (Run (ConvertFromSpec s)), Component (ConvertFromSpec s), RunInEnv (Run (ConvertFromSpec s)) (Env b)) Source #
necessary constraints of the resulting type
compile :: b -> s -> Env b (ConvertFromSpec s) Source #
compile the specification to runnable component.
data SpecConvolution Source #
Specification: convolution layer
Convolution Int Int Int | number of output channels, size of kernel, size of padding |