neural-network-base-0.1.0.0: Yet Another High Performance and Extendable Neural Network in Haskell

Copyright(c) 2016 Jiasen Wu
LicenseBSD-style (see the file LICENSE)
MaintainerJiasen Wu <jiasenwu@hotmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Data.NeuralNetwork

Description

This module defines an abstract interface for neural network and a protocol for its backends to follow.

Synopsis

Documentation

class Component a where Source #

Abstraction of a neural network component

Minimal complete definition

forwardT, output, backward

Associated Types

type Run a :: * -> * Source #

execution environment

type Inp a Source #

the type of input and in-error

type Out a Source #

the type of output and out-error

data Trace a Source #

the trace of a forward propagation

Methods

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

learn Source #

Arguments

:: (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.

relu :: (Num a, Ord a) => a -> a Source #

default RELU and derivative of RELU

relu' :: (Num a, Ord a) => a -> a Source #

default RELU and derivative of RELU

cost' :: (Num a, Ord a) => a -> a -> a Source #

default derivative of error measurement

class Backend b s where Source #

Abstraction of backend to carry out the specification

Minimal complete definition

witness, compile

Associated Types

type Env b :: * -> * Source #

environment to compile the specification

type ConvertFromSpec s :: * Source #

result type of compile

Methods

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.

class (Monad r, Monad e) => RunInEnv r e where Source #

Lifting from one monad to another. It is not necessary that the Env and Run maps to the same execution environment, but the Run one should be able to be lifted to Env one.

Minimal complete definition

run

Methods

run :: r a -> e a Source #

data a :++ b infixr 0 Source #

Specification: stacking layer

Constructors

a :++ b infixr 0 

data SpecIn1D Source #

Specification: 1D input

Constructors

In1D Int

dimension of input

data SpecIn2D Source #

Specification: 2D input

Constructors

In2D Int Int

dimension of input

data SpecReshape2DAs1D Source #

Specification: reshaping layer

Constructors

Reshape2DAs1D 

data SpecFullConnect Source #

Specification: full connection layer

Constructors

FullConnect Int

number of neurals

data SpecConvolution Source #

Specification: convolution layer

Constructors

Convolution Int Int Int

number of output channels, size of kernel, size of padding

data SpecMaxPooling Source #

Specification: max pooling layer

Constructors

MaxPooling Int