Portability | portable |
---|---|
Stability | experimental |
Maintainer | robert.steuck@gmail.com |
Basic backpropagation neuronal network inspired by hnn
- type ALayer a = [(Neuron, a)]
- type ANetwork a = [ALayer a]
- type Network = ANetwork ()
- data ForwardPassInfo = FPInfo {}
- data Neuron = Neuron {}
- type PackedNeuron = [Double]
- sigmoid :: Double -> Double
- sigmoid' :: Double -> Double
- type NeuronCreator = PackedNeuron -> Neuron
- sigmoidNeuron :: PackedNeuron -> Neuron
- outputNeuron :: PackedNeuron -> Neuron
- biasNeuron :: Int -> Neuron
- createLayer :: [PackedNeuron] -> NeuronCreator -> ALayer ()
- sigmoidLayer :: [PackedNeuron] -> ALayer ()
- outputLayer :: [PackedNeuron] -> ALayer ()
- createRandomNetwork :: Int -> [Int] -> Network
- icNcToPackedNeurons :: Int -> Int -> [Double] -> ([PackedNeuron], [Double])
- unpackNetwork :: [[PackedNeuron]] -> Network
- packNetwork :: Network -> [[PackedNeuron]]
- passForward :: Network -> [Double] -> ANetwork ForwardPassInfo
- passForward' :: ALayer a -> [Double] -> ALayer ForwardPassInfo
- passForward'' :: Neuron -> [Double] -> ForwardPassInfo
- calcNet :: [Double] -> [Double] -> Double
- weightUpdate :: Double -> ANetwork ForwardPassInfo -> [Double] -> Network
- weightUpdate' :: Double -> ALayer ForwardPassInfo -> (Network, [Double]) -> (Network, [Double])
- weightUpdate'' :: Double -> (Neuron, ForwardPassInfo) -> Double -> (Neuron, Double)
- backprop :: Double -> Network -> ([Double], [Double]) -> Network
- calculate :: Network -> [Double] -> [Double]
- calculate' :: [Double] -> ALayer a -> [Double]
- quadErrorNet :: Network -> ([Double], [Double]) -> Double
- globalQuadError :: Network -> [([Double], [Double])] -> Double
- trainAlot :: Double -> Network -> [([Double], [Double])] -> [Network]
- train :: Double -> Double -> Network -> [([Double], [Double])] -> Network
Types for computation
data ForwardPassInfo Source
information generated during a simple forward pass
the neuron
Types for serialisation
type PackedNeuron = [Double]Source
Activation functions
Network creation
type NeuronCreator = PackedNeuron -> NeuronSource
outputNeuron :: PackedNeuron -> NeuronSource
activation function is id
createLayer :: [PackedNeuron] -> NeuronCreator -> ALayer ()Source
sigmoidLayer :: [PackedNeuron] -> ALayer ()Source
outputLayer :: [PackedNeuron] -> ALayer ()Source
serialisation deserialization
icNcToPackedNeurons :: Int -> Int -> [Double] -> ([PackedNeuron], [Double])Source
unpackNetwork :: [[PackedNeuron]] -> NetworkSource
packNetwork :: Network -> [[PackedNeuron]]Source
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
weight update
:: Double | learning rate |
-> 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
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