Installing FANN with Python bindings on Ubuntu

fann

The Fast Artificial Neural Network Library (FANN) is a neural network library, which implements multilayer artificial neural networks in C with support for both fully connected and sparsely connected networks. It has a Python binding that allows you to use its functionality from within Python, but with the bits that need speed implemented in C.

We are going to install the FANN library on Ubuntu and install the Python binding. Get and unzip the library:

wget http://downloads.sourceforge.net/project/fann/fann/2.1.0beta/fann-2.1.0beta.zip
sudo apt-get install unzip
unzip fann-2.1.0beta.zip

Configure, make and install the library:

cd fann-2.1.0/
sudo apt-get install gcc make
./configure
make
sudo make install

Install the Python bindings:

cd python/
sudo apt-get install g++ python-dev swig
sudo python setup.py install

The Python files are now located in a build directory. Copy them to a place where you can use them, e.g. your home directory:

cd build/lib.linux-i686-2.6/pyfann/
cp libfann.py ~
cp _libfann.so ~

And finally test that Python can now work with the library, start up Python and type:

import libfann
print dir(libfann)

This should print out all the functions of the library.

2 Responses

Write a Comment»
  1. Really useful and straightforward. Thanks for sharing!

  2. Just two notes, in case it can be useful to whoever reads this “howto”.

    In case you get troubles installing this binding on a x86-64 system, you can get help in this link:
    http://leenissen.dk/fann/forum/viewtopic.php?f=1&t=478&p=2899#p2899

    And one question: wouldn’t be a better choice something like /usr/lib/ in order to place the libraries in order to be accessible from whatever dir we’re working on?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>