Copyright | (c) Alexander Ignatyev 2016 |
---|---|
License | BSD-3 |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
MachineLearning.NeuralNetwork
Description
Simple Neural Networks.
- class Model a where
- newtype NeuralNetworkModel = NeuralNetwork Topology
- calcAccuracy :: Vector -> Vector -> R
- data Topology
- initializeTheta :: Int -> Topology -> Vector
- initializeThetaIO :: Topology -> IO Vector
- initializeThetaM :: RandomGen g => Topology -> Rand g Vector
- data Regularization
Documentation
Minimal complete definition
Methods
hypothesis :: a -> Matrix -> Vector -> Vector Source #
Hypothesis function, a.k.a. score function (for lassifition problem) Takes X (m x n) and theta (n x 1), returns y (m x 1).
cost :: a -> Regularization -> Matrix -> Vector -> Vector -> R Source #
Cost function J(Theta), a.k.a. loss function. It takes regularizarion parameter, matrix X (m x n), vector y (m x 1) and vector theta (n x 1).
gradient :: a -> Regularization -> Matrix -> Vector -> Vector -> Vector Source #
Gradient function. It takes regularizarion parameter, X (m x n), y (m x 1) and theta (n x 1). Returns vector of gradients (n x 1).
Instances
newtype NeuralNetworkModel Source #
Neural Network Model. Takes neural network topology as a constructor argument.
Constructors
NeuralNetwork Topology |
Instances
calcAccuracy :: Vector -> Vector -> R Source #
Calculates accuracy of Classification predictions. Takes vector expected y and vector predicted y. Returns number from 0 to 1, the closer to 1 the better accuracy. Suitable for both Classification Types: Binary and Multiclass.
Neural network topology has at least 2 elements: numver of input and number of outputs. And sizes of hidden layers between 2 elements.
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.
initializeThetaM :: RandomGen g => Topology -> Rand g Vector Source #
Create and initialize weights vector with random values for given neural network topology inside RandomMonad.