Libann: Using Libann in your Programs |
|
2. Using Libann in your ProgramsThere are no special features that you need to know about when using Libann, that don't also apply to other C++ libraries. However, the effects of ignoring them might be more severe than with simpler programs. This chapter is largely a memorandum for persons not thoroughly familiar with C++ programming. If you're an expert with C++, then you can skip this chapter, or just give it a cursory glance.
2.1 NamespacesEverything provided by Libann is in theann namespace.
Therefore, your code should:
If you don't do one of these, then your compiler won't recognise any identifiers from the library. This is a feature designed to prevent clashes with symbols from other libraries or from other parts of your own program.
2.2 Public Header FilesThere is a public header file for each type of Neural Network provided by the library. For example if you want to use a Multi-Layer Perceptron network, then you must include the `ann/mlp.h' file. All#include statements must have the ann/ prefix, and
on most compilers should be enclosed by angle brackets.
For example:
As well as a header file for each network type, there is a common file, `ann/ann.h' which contains declarations for classes which you'll almost definitely need if you're going to do anything useful with Libann. More about this header file later.
2.3 ExceptionsThe library throws exceptions! Most often, an exception means that you have provided invalid data to a Neural Network. For example, if you pass a vector to a network which has the wrong input size, then you'll definitely get an exception.This is not to say that all exceptions are errors. Exceptions should be thought of as exactly what their name suggests, viz: things which happen only in exceptional circumstances. For example you might know that most of your vectors are the appropriate size for a network, but that there are the occasional few which are not. In that case, you could catch the exception and deal with the few cases as they arise.
The potential to throw exceptions however, means that you must
protect your
There is nothing new here.
Any C++ program should have this (or something similar) in its
2.4 RandomnessMany types of neural network depend upon random initialisation. This is important to ensure that solutions do not fall into local minima or become biased towards a particular solution. The library uses the standard `libc' callrand() to generate its random numbers.
Therefore, before using Libann, your program should make a call to
2.5 Compiling and Linking with LibannThere's nothing special about compiling and linking a program with Libann. Assuming that you have installed Libann in a directory called `/usr/local/libann', on most systems, you would use a command line similar to
make or some
other build tool to assist you.
This document was generated by John Darrington on May, 15 2003 using texi2html |