Copyright | (c) Alexander Ignatyev 2017 |
---|---|

License | BSD-3 |

Stability | experimental |

Portability | POSIX |

Safe Haskell | None |

Language | Haskell2010 |

Neural Network's Topology

- data Topology
- type LossFunc = Matrix -> Matrix -> R
- makeTopology :: Int -> [Layer] -> Layer -> LossFunc -> Topology
- loss :: Topology -> Regularization -> Matrix -> [(Matrix, Matrix)] -> Matrix -> R
- propagateForward :: Topology -> Matrix -> [(Matrix, Matrix)] -> (Matrix, [Cache])
- propagateBackward :: Topology -> Regularization -> Matrix -> [Cache] -> Matrix -> [(Matrix, Matrix)]
- numberOutputs :: Topology -> Int
- initializeTheta :: Int -> Topology -> Vector
- initializeThetaIO :: Topology -> IO Vector
- initializeThetaM :: RandomGen g => Topology -> Rand g Vector
- flatten :: [(Matrix, Matrix)] -> Vector
- unflatten :: Topology -> Vector -> [(Matrix, Matrix)]

# Documentation

Neural network topology has at least 2 elements: numver of input and number of outputs. And sizes of hidden layers between 2 elements.

makeTopology :: Int -> [Layer] -> Layer -> LossFunc -> Topology Source #

Makes Neural Network's Topology. Takes number of inputs, list of hidden layers, output layer and loss function.

loss :: Topology -> Regularization -> Matrix -> [(Matrix, Matrix)] -> Matrix -> R Source #

Calculates loss for the given topology. Takes topology, regularization, x, weights, y.

propagateForward :: Topology -> Matrix -> [(Matrix, Matrix)] -> (Matrix, [Cache]) Source #

Implementation of forward propagation algorithm.

propagateBackward :: Topology -> Regularization -> Matrix -> [Cache] -> Matrix -> [(Matrix, Matrix)] Source #

Implementation of backward propagation algorithm.

numberOutputs :: Topology -> Int Source #

Returns number of outputs of the given topology.

initializeTheta :: Int -> Topology -> Vector Source #

Create and initialize weights vector with random values for given neural network topology. Takes a seed to initialize generator of random numbers as a first parameter.

initializeThetaIO :: Topology -> IO Vector Source #

Create and initialize weights vector with random values for given neural network topology inside IO Monad.