-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A minimal Haskell Neural Network Library -- -- hnn provides minimal types and functions to create, train and use feed -- forward neural networks http://www.haskell.org/haskellwiki/HNN @package hnn @version 0.1 -- | Neuron module, defining an artificial neuron type and the basical -- operations we can do on it module AI.HNN.Neuron -- | Our Artificial Neuron type data Neuron Neuron :: Double -> UArr Double -> (Double -> Double) -> Neuron threshold :: Neuron -> Double weights :: Neuron -> UArr Double func :: Neuron -> Double -> Double -- | Creates a Neuron with the given threshold, weights and transfer -- function createNeuronU :: Double -> UArr Double -> (Double -> Double) -> Neuron -- | Equivalent to `createNeuronU t ws heavyside' createNeuronHeavysideU :: Double -> UArr Double -> Neuron -- | Equivalent to `createNeuronU t ws sigmoid' createNeuronSigmoidU :: Double -> UArr Double -> Neuron -- | Same as createNeuronU, with a list instead of an UArr for the weights -- (converted to UArr anyway) createNeuron :: Double -> [Double] -> (Double -> Double) -> Neuron -- | Same as createNeuronHeavysideU, with a list instead of an UArr for the -- weights (converted to UArr anyway) createNeuronHeavyside :: Double -> [Double] -> Neuron -- | Same as createNeuronSigmoidU, with a list instead of an UArr for the -- weights (converted to UArr anyway) createNeuronSigmoid :: Double -> [Double] -> Neuron -- | The Heavyside function heavyside :: Double -> Double -- | The Sigmoid function sigmoid :: Double -> Double -- | Computes the output of a given Neuron for given inputs computeU :: Neuron -> UArr Double -> Double -- | Computes the output of a given Neuron for given inputs compute :: Neuron -> [Double] -> Double -- | Trains a neuron with the given sample, of the form (inputs, -- wanted_result) and the given learning ratio (alpha) learnSampleU :: Double -> Neuron -> (UArr Double, Double) -> Neuron learnSample :: Double -> Neuron -> ([Double], Double) -> Neuron -- | Trains a neuron with the given samples and the given learning ratio -- (alpha) learnSamplesU :: Double -> Neuron -> [(UArr Double, Double)] -> Neuron -- | Trains a neuron with the given samples and the given learning ratio -- (alpha) learnSamples :: Double -> Neuron -> [([Double], Double)] -> Neuron instance Show Neuron -- | Layer module, defining functions to work on a neural network layer, -- which is a list of neurons module AI.HNN.Layer -- | Creates a layer compound of n neurons with the Sigmoid transfer -- function, all having the given threshold and weights. createSigmoidLayerU :: Int -> Double -> UArr Double -> [Neuron] -- | Creates a layer compound of n neurons with the Heavyside transfer -- function, all having the given threshold and weights. createHeavysideLayerU :: Int -> Double -> UArr Double -> [Neuron] -- | Creates a layer compound of n neurons with the sigmoid transfer -- function, all having the given threshold and weights. createSigmoidLayer :: Int -> Double -> [Double] -> [Neuron] -- | Creates a layer compound of n neurons with the sigmoid transfer -- function, all having the given threshold and weights. createHeavysideLayer :: Int -> Double -> [Double] -> [Neuron] -- | Computes the outputs of each Neuron of the layer computeLayerU :: [Neuron] -> UArr Double -> UArr Double -- | Computes the outputs of each Neuron of the layer computeLayer :: [Neuron] -> [Double] -> [Double] -- | Trains each neuron with the given sample and the given learning ratio learnSampleLayerU :: Double -> [Neuron] -> (UArr Double, UArr Double) -> [Neuron] -- | Trains each neuron with the given sample and the given learning ratio learnSampleLayer :: Double -> [Neuron] -> ([Double], [Double]) -> [Neuron] -- | Trains each neuron with the given samples and the given learning ratio learnSamplesLayerU :: Double -> [Neuron] -> [(UArr Double, UArr Double)] -> [Neuron] -- | Trains each neuron with the given samples and the given learning ratio learnSamplesLayer :: Double -> [Neuron] -> [([Double], [Double])] -> [Neuron] -- | Returns the quadratic error of a layer for a given sample quadErrorU :: [Neuron] -> (UArr Double, UArr Double) -> Double -- | Returns the quadratic error of a layer for a given sample quadError :: [Neuron] -> ([Double], [Double]) -> Double -- | Net module, defining functions to work on a neural network, which is a -- list of list of neurons module AI.HNN.Net check :: [[Neuron]] -> Bool nn :: [[Neuron]] -> [[Neuron]] -- | Computes the output of the given neural net on the given inputs computeNetU :: [[Neuron]] -> UArr Double -> UArr Double -- | Computes the output of the given neural net on the given inputs computeNet :: [[Neuron]] -> [Double] -> [Double] -- | Returns the quadratic error of the neural network on the given sample quadErrorNetU :: [[Neuron]] -> (UArr Double, UArr Double) -> Double -- | Returns the quadratic error of the neural network on the given sample quadErrorNet :: [[Neuron]] -> ([Double], [Double]) -> Double -- | Returns the quadratic error of the neural network on the given samples globalQuadErrorNetU :: [[Neuron]] -> [(UArr Double, UArr Double)] -> Double -- | Returns the quadratic error of the neural network on the given samples globalQuadErrorNet :: [[Neuron]] -> [([Double], [Double])] -> Double -- | Train the given neural network using the backpropagation algorithm on -- the given sample with the given learning ratio (alpha) backPropU :: Double -> [[Neuron]] -> (UArr Double, UArr Double) -> [[Neuron]] -- | Train the given neural network using the backpropagation algorithm on -- the given sample with the given learning ratio (alpha) backProp :: Double -> [[Neuron]] -> ([Double], [Double]) -> [[Neuron]] trainAux :: Double -> [[Neuron]] -> [(UArr Double, UArr Double)] -> [[Neuron]] -- | Train the given neural network on the given samples using the -- backpropagation algorithm using the given learning ratio (alpha) and -- the given desired maximal bound for the global quadratic error on the -- samples (epsilon) trainU :: Double -> Double -> [[Neuron]] -> [(UArr Double, UArr Double)] -> [[Neuron]] -- | Train the given neural network on the given samples using the -- backpropagation algorithm using the given learning ratio (alpha) and -- the given desired maximal bound for the global quadratic error on the -- samples (epsilon) train :: Double -> Double -> [[Neuron]] -> [([Double], [Double])] -> [[Neuron]]