bpann-0.1.1: backpropagation neuronal network

Portabilityportable
Stabilityexperimental
Maintainerrobert.steuck@gmail.com

AI.BPANN

Contents

Description

Basic backpropagation neuronal network inspired by hnn

Synopsis

Types for computation

type ALayer a = [(Neuron, a)]Source

type ANetwork a = [ALayer a]Source

data ForwardPassInfo Source

information generated during a simple forward pass

Constructors

FPInfo 

Fields

o :: Double

output

net :: Double

sum of weighted inputs

xs :: [Double]

inputs

data Neuron Source

the neuron

Constructors

Neuron 

Fields

ws :: [Double]

input weights

fun :: Double -> Double

activation function

fun' :: Double -> Double

first derivation of the activation function

Instances

Types for serialisation

Activation functions

sigmoid :: Double -> DoubleSource

1/(1+e^(-x))

sigmoid' :: Double -> DoubleSource

first derivation

Network creation

outputNeuron :: PackedNeuron -> NeuronSource

activation function is id

biasNeuronSource

Arguments

:: Int

number of inputs

-> Neuron 

createRandomNetworkSource

Arguments

:: Int

seed for random weigth generator

-> [Int]

number of neurons per layer

-> Network 

serialisation deserialization

backpropagation algorithm

forward pass

passForward :: Network -> [Double] -> ANetwork ForwardPassInfoSource

generate forward pass info for a network

passForward' :: ALayer a -> [Double] -> ALayer ForwardPassInfoSource

generate forward pass info for a layer

passForward'' :: Neuron -> [Double] -> ForwardPassInfoSource

generate forward pass info for a neuron

calcNet :: [Double] -> [Double] -> DoubleSource

calculate the weigtet input of the neuron

weight update

weightUpdateSource

Arguments

:: Double

learning rate alpha

-> ANetwork ForwardPassInfo 
-> [Double]

desired output value

-> Network 

updates the weigts for an entire network

weightUpdate' :: Double -> ALayer ForwardPassInfo -> (Network, [Double]) -> (Network, [Double])Source

updates the weigts for a layer

weightUpdate'' :: Double -> (Neuron, ForwardPassInfo) -> Double -> (Neuron, Double)Source

updates the weigts for a neuron

forward pass and weigtupdate put together

backpropSource

Arguments

:: Double

learning rate alpha

-> Network 
-> ([Double], [Double])

inpit and desired output

-> Network 

Evaluation

calculate :: Network -> [Double] -> [Double]Source

calculates the output of a network for a given input vector

calculate' :: [Double] -> ALayer a -> [Double]Source

calculates the output of a layer for a given input vector

Training

quadErrorNet :: Network -> ([Double], [Double]) -> DoubleSource

quadratic error for a single vector pair

globalQuadError :: Network -> [([Double], [Double])] -> DoubleSource

quadratic error for for multiple pairs

trainAlotSource

Arguments

:: Double

learning rate alpha

-> Network 
-> [([Double], [Double])]

list of pairs of input and desired output

-> [Network] 

produces an indefinite sequence of networks

trainSource

Arguments

:: Double

learning rate alpha

-> Double

the maximum error epsilon

-> Network 
-> [([Double], [Double])]

list of pairs of input and desired output

-> Network 

trains a network with a set of vector pairs until a the globalQuadError is smaller than epsilon