Click here to Skip to main content
15,880,543 members
Articles / Artificial Intelligence

Artificial Neural Networks made easy with the FANN library

Rate me:
Please Sign up or sign in to vote.
4.93/5 (46 votes)
28 Aug 2013CPOL24 min read 194.1K   10.6K   206  
Neural networks are typically associated with specialised applications, developed only by select groups of experts. This misconception has had a highly negative effect on its popularity. Hopefully, the FANN library will help fill this gap.
from distutils.core import setup, Extension
from distutils.command.install_data import install_data
from compiler.pycodegen import compileFile
import glob
import distutils
import distutils.sysconfig
import distutils.core
import os
import py2exe

VERSION='1.2.0'

LONG_DESCRIPTION="""\
Fast Artificial Neural Network Library implements multilayer
artificial neural networks with support for both fully connected
and sparsely connected networks. It includes a framework for easy 
handling of training data sets. It is easy to use, versatile, well 
documented, and fast. 
"""

class smart_install_data(install_data):
    """
    override default distutils install_data, so we can copy
    files directly, without splitting into modules, scripts,
    packages, and extensions."
    """
    def run(self):
        # need to change self.install_dir to the actual library dir

        install_cmd = self.get_finalized_command('install')
        self.install_dir = getattr(install_cmd, 'install_lib')
        return install_data.run(self)

def hunt_files(root, which):
    return glob.glob(os.path.join(root, which))

data_files = []

# add sources
data_files = data_files + [['', ['fann.py', '__init__.py']]]

# add dll and swig output
compileFile('libfann.py')
data_files = data_files + [['', ['libfann.pyc', '_libfann.pyd']]]

# add examples
data_files = data_files + [['examples', hunt_files('examples', '*.py')]]

# add examples datasets
data_files = data_files + [['examples/datasets', hunt_files('../benchmarks/datasets', 'mushroom*')]]
data_files = data_files + [['examples/datasets', hunt_files('../examples', 'xor.data')]]

setup(
    name='pyfann',
    description='Fast Artificial Neural Network Library (fann)',
    long_description=LONG_DESCRIPTION,
    version=VERSION,
    author='Steffen Nissen',
    author_email='lukesky@diku.dk',
    maintainer='Gil Megidish',
    maintainer_email='gil@megidish.net',
    url='http://sourceforge.net/projects/fann/',
    platforms='WIN32',
    license='GNU LESSER GENERAL PUBLIC LICENSE (LGPL)',
    data_files=data_files,
    cmdclass={'install_data': smart_install_data},
    extra_path='pyfann'
)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Publisher
Poland Poland
Software Developer's Journal (formerly Software 2.0) is a magazine for professional programmers and developers publishing news from the software world and practical articles presenting very interesting ready programming solutions. To read more

Comments and Discussions