hfann-0.2: Haskell binding to the FANN library

Portabilityportable
Stabilityexperimental
Maintainerolivier.boudry@gmail.com

HFANN

Contents

Description

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 (http://leenissen.dk/fann/).

HFANN is a Haskell interface to this library.

See below for examples.

Synopsis

Documentation

module HFANN.Base

module HFANN.Data

module HFANN.IO

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