FANN is a very good neural network library written in C for speed. It is very easy to install this library in mac. There is also limited possibility on getting this library run on GPU (opencl) (check the forums http://leenissen.dk/fann/forum/viewtopic.php?f=2&t=658) . Lets see how we can install this library properly. This library should run faster than pybrain

Screen Shot 2014-11-05 at 5.28.46 pm

1. First download install Xcode and command line tools in your mac.

2. Install brew (alternative for apt-get in linux)

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3. Install cmake

sudo brew install cmake

4. Download the .tar.gz file and unpack it

cmake
sudo make install

5. Compile the examples to make all the executables

cd examples
make all

6. Run the example program

./xor_train

and you should see some output like this. This means our FANN is working! Ooohooo!

$ ./xor_train
Creating network.
Training network.
Max epochs     1000. Desired error: 0.0000000000.
Epochs            1. Current error: 0.3306783140. Bit fail 4.
Epochs           10. Current error: 0.1138807014. Bit fail 4.
Epochs           20. Current error: 0.0015137990. Bit fail 4.
Epochs           23. Current error: 0.0000326863. Bit fail 0.
Testing network. 0.000005
XOR test (-1.000000,-1.000000) -> -0.994146, should be -1.000000, difference=0.005854
XOR test (-1.000000,1.000000) -> 0.995911, should be 1.000000, difference=0.004089
XOR test (1.000000,-1.000000) -> 0.997842, should be 1.000000, difference=0.002158
XOR test (1.000000,1.000000) -> -0.995165, should be -1.000000, difference=0.004835
Saving network.

7. When you write a new C program, you can compile in the commandline like this

gcc test.c -o test -lfann -lm