----------------------------------------------------------------------------- -- | -- Module : HFANN -- Copyright : (c) Olivier Boudry 2008 -- License : BSD-style (see the file LICENSE) -- -- Maintainer : olivier.boudry@gmail.com -- Stability : experimental -- Portability : portable -- -- The Fast Artificial Neural Network Library (FANN) is a free open source -- neural network library written in C with support for both fully connected -- and sparsely connected networks (). -- -- HFANN is a Haskell interface to this library. -- -- See below for examples. -- ----------------------------------------------------------------------------- module HFANN ( module HFANN.Base, module HFANN.Data, module HFANN.IO, module HFANN.Train, -- * Examples -- $examples ) where import HFANN.Base import HFANN.Data import HFANN.IO import HFANN.Train -- --------------------------------------------------------------------------- -- $examples -- Training an Artificial Neural Network (ANN) to the \'xor\' function: -- -- > import HFANN -- > -- > -- Nodes definition for an ANN of 2 input, 3 hidden and 1 output nodes -- > fannDef :: [Int] -- > fannDef = [2, 3, 1] -- > -- > main :: IO () -- > main = do -- > -- Create a new ANN -- > withStandardFann fannDef $ \fann -> do -- > -- Replace the default activation function 'fannSigmoid' with -- > -- a symmetric one -- > setActivationFunctionHidden fann fannSigmoidSymmetric -- > setActivationFunctionOutput fann fannSigmoidSymmetric -- > -- > -- Train the ANN on the data from file \'xor.data\' -- > trainOnFile fann "xor.data" 200000 100 0.001 -- > -- > -- Save the trained ANN to file \'xor.ann\' -- > saveFann fann "xor.ann" -- -- Using a saved ANN trained to the \'xor\' function: -- -- > import HFANN -- > -- > fileName :: String -- > fileName = "xor.ann" -- > -- > main :: IO () -- > main = do -- > -- Load an ANN from file \'xor.ann\' -- > withSavedFann fileName $ \fann -> do -- > -- Run the ANN on input [1,-1] -- > res <- runFann fann [1,-1] -- > print res