Neural Networks Made Simple - FANN - SourceForge

9 downloads 193 Views 930KB Size Report
ficial neural network (ANN) is built to model the human brain's own neural network. The Fast Artificial Neural. Network (FANN) library is an ANN library, which ...
Artificial Intelligence

Steffen Nissen

On the CD: Full documentation concerning the Fann library (the files including source code as well as the Fann library version) can be found on the CD.

Neural Networks Made Simple

F

or years, the Hollywood science fiction films such as I, Robot have portrayed an artificial intelligence (AI) as a harbinger of Armageddon. Nothing, however, could be farther from the truth. While Hollywood regales us with horror stories of our imminent demise, people with no interest in the extinction of our species have been harnessing AI to make our lives easier, more productive, longer and generally better. The robots in the I, Robot film have an artificial brain based on a network of artificial neurons; this artificial neural network (ANN) is built to model the human brain's own neural network. The Fast Artificial Neural Network (FANN) library is an ANN library, which can be used from C, C++, PHP, Python, Delphi and Mathematica and although, it cannot create Hollywood magic, it is still a powerful tool for software developers. ANNs can be used in areas as diverse as creating more appealing game-play in computer games, identifying objects in images and helping the stock brokers predict trends of the ever-changing stock market.

Function approximation

ANNs apply the principle of function approximation by example, meaning that they learn a function by looking at examples of this function. One of the simplest examples is an ANN learning the XOR function, but it could just as easily be learning to determine the language of a text, or whether there is a tumour visible in an X-ray image. If an ANN is to be able to learn a problem, it must be defined as a function with a set of input and output variables supported by examples of how this function should work. A problem like the XOR function is already defined as a function with two binary input variables and a binary output variable, and with the examples which are defined by the results of four different input patterns. However, there are more complicated problems which can be more difficult to define as functions. The input variables to the problem of finding a tumour in an X-ray image could be the pixel values of the image, but they could also be some values extracted from the image. The output could then either be a binary value or a floatingSteffen Nissen is a Computer Scientist from Denmark. He has created and actively maintained the FANN library, while the others maintain the bindings for other languages. He is also the author of technical report covering the creation of FANN library, Implementation of a Fast Artificial Neural Network Library (fann). Contact the author: [email protected]

14

Figure 1. An ANN with four input neurons, a hidden layer and four output neurons point value representing the probability of a tumour in the image. In ANNs this floating-point value would normally be between 0 and 1, inclusive.

The human brain

A function approximator like an ANN can be viewed as a black box and when it comes to FANN, this is more or less all you will need to know. However, basic knowledge of how the human brain operates is needed to understand how ANNs work. The human brain is a highly complicated system which is capable to solve very complex problems. The brain consists of many different elements, but one of its most important building blocks is the neuron, of which it contains approximately 1011. These neurons are connected by around 1015 connections, creating a huge neural network. Neurons send impulses to each other through the connections and these impulses make the brain work. The neural network also receives impulses from the five senses and sends out impulses to muscles to achieve motion or speech. The individual neuron can be seen as an inputoutput machine which waits for impulses from the surrounding neurons and, when it has received enough impulses, it sends out an impulse to other neurons.

Artificial Neural Networks

Artificial neurons are similar to their biological counterparts. They have input connections which are summed together to determine the strength of their output, which is the result of the sum being fed into an activation function. Though many activation functions exist, the most common is the sigmoid activation function, which outputs a number between 0 (for low input values) and 1 (for high input values). The resultant of this function is then passed as the input to other neurons through more connections, each of which are weighted. These weights determine the behaviour of the network.

www.software20.org

Software 2.0

2/2005

Fast Artificial Neural Network Library

Listing 1. Program that calculates the frequencies of the letters A-Z in a text file #include #include #include #include void error(const char* p, const char* p2 = "") {

std::cerr