Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

annie::MultiLayerNetwork Class Reference

#include <MultiLayerNetwork.h>

Inheritance diagram for annie::MultiLayerNetwork:

annie::Network annie::TwoLayerNetwork List of all members.

Public Methods

 MultiLayerNetwork (int inputs)
 MultiLayerNetwork (MultiLayerNetwork &srcNet)
 Copy constructor, NOT YET IMPLEMENTED. More...

 MultiLayerNetwork (const char *filename)
virtual ~MultiLayerNetwork ()
virtual void addLayer (int size)
 Adds a layer of the given size to the network. This new layer becomes the output layer. More...

virtual void connectLayer (int srcLayer)
virtual void connect (int srcLayer, int srcNrn, int destNrn)
virtual void connect (int srcLayer, int srcNrn, int destNrn, real weight)
virtual void setBias (int layer, int nrn, real bias)
virtual int getLayerCount ()
 The number of layers in the network (does not count the input layer as a layer). More...

virtual VECTOR getOutput (VECTOR &input)
virtual VECTOR getOutput (real *input)
virtual void train (TrainingSet &T, int epochs, real learningRate, real momentum=0.0)
virtual void train (TrainingSet &T, int epochs, real learningRate, real momentum, bool verbose)
virtual void save (const char *filename)
virtual void setActivationFunction (int layer, ActivationFunction f, ActivationFunction df)
virtual const char * getClassName ()
 Returns "MultiLayerNetwork". More...


Protected Methods

InputLayer_inputLayer ()
 The input layer. More...

Layer_outputLayer ()
 The output layer. More...


Protected Attributes

int _nLayers
std::vector< Layer * > _layers
 The layers. More...


Detailed Description

Abstraction of a multi-layer perceptron network. Basically, layers of SimpleNeurons constitute this network. Training is done using the backpropagation technique which uses the gradient descent method.

The labels of the layers start from 0 (for the input layer) and then keep moving on. The labels of neurons in the layers is = <layer label>*Layer::MAX_LAYER_SIZE + <neuron index in layer>

All neurons in the layers are allowed to have a bias.

Todo:
The copy constructor


Constructor & Destructor Documentation

annie::MultiLayerNetwork::MultiLayerNetwork int    inputs
 

Create a multi-layer network.

Parameters:
inputs  The number of inputs taken in by the network

annie::MultiLayerNetwork::MultiLayerNetwork MultiLayerNetwork &    srcNet
 

Copy constructor, NOT YET IMPLEMENTED.

annie::MultiLayerNetwork::MultiLayerNetwork const char *    filename
 

Loads a multi-layer network from the given filename.

Parameters:
filename  The name of the file from which to load the network
Exceptions:
Exception  On any error

virtual annie::MultiLayerNetwork::~MultiLayerNetwork   [virtual]
 


Member Function Documentation

InputLayer* annie::MultiLayerNetwork::_inputLayer   [protected]
 

The input layer.

Layer* annie::MultiLayerNetwork::_outputLayer   [protected]
 

The output layer.

virtual void annie::MultiLayerNetwork::addLayer int    size [virtual]
 

Adds a layer of the given size to the network. This new layer becomes the output layer.

Reimplemented in annie::TwoLayerNetwork.

virtual void annie::MultiLayerNetwork::connect int    srcLayer,
int    srcNrn,
int    destNrn,
real    weight
[virtual]
 

Connects two neurons, with the weight provided.

Parameters:
srcLayer  The index of the layer in which the source neuron lies
srcNrn  The index of the source neuron in the source layer
destNrn  The index of the destination neuron (will be in the layer with index srcLayer+1)
weight  The weight of the link
Exceptions:
Exception  On any invalid argument values

virtual void annie::MultiLayerNetwork::connect int    srcLayer,
int    srcNrn,
int    destNrn
[virtual]
 

Connects two neurons, with random weight

Parameters:
srcLayer  The index of the layer in which the source neuron lies
srcNrn  The index of the source neuron in the source layer
destNrn  The index of the destination neuron (will be in the layer with index srcLayer+1)
Exceptions:
Exception  On any invalid argument values

virtual void annie::MultiLayerNetwork::connectLayer int    srcLayer [virtual]
 

Completely connects the given layer with the layer below it, i.e., all neurons in the given layer will give their output to all the neurons in the layer below. Weights are random.

Parameters:
srcLayer  The index of the source layer
Exceptions:
Exception  If the layer index provided is invalid

virtual const char* annie::MultiLayerNetwork::getClassName   [virtual]
 

Returns "MultiLayerNetwork".

Implements annie::Network.

Reimplemented in annie::TwoLayerNetwork.

virtual int annie::MultiLayerNetwork::getLayerCount   [virtual]
 

The number of layers in the network (does not count the input layer as a layer).

virtual VECTOR annie::MultiLayerNetwork::getOutput real   input [virtual]
 

Wrapper function to allow getOutput() to work for an array of real as input as well. Does exactly the same thing as Network::getOutput(real*).

Reimplemented from annie::Network.

virtual VECTOR annie::MultiLayerNetwork::getOutput VECTOR   input [virtual]
 

Returns the output of the network for the given input.

Parameters:
input  A vector of getDimension() reals
Returns:
The corresponding output of the network

Implements annie::Network.

virtual void annie::MultiLayerNetwork::save const char *    filename [virtual]
 

Saves the network to the given filename. The file is a simple text file, open it up in a text editor to see the format, quite simple

Parameters:
filename  The name of the file to save the network in.

Implements annie::Network.

virtual void annie::MultiLayerNetwork::setActivationFunction int    layer,
ActivationFunction    f,
ActivationFunction    df
[virtual]
 

Sets the activation function used by the neurons in the provided layer.

Parameters:
layer  The layer whose activation function is to be changed. layer>0 (as input neurons don't have any activation function) and layer<getLayerCount()
f  The activation function to be used
df  The derivative of the activation function to be used. Required for training.
Exceptions:
Exception  if an invalid layer is given

virtual void annie::MultiLayerNetwork::setBias int    layer,
int    nrn,
real    bias
[virtual]
 

Sets the bias of the given neuron.

Parameters:
layer  The index of the layer in which the neuron lies
nrn  The index of the neuron in the layer
bias  The bias to be given to the neuron

virtual void annie::MultiLayerNetwork::train TrainingSet   T,
int    epochs,
real    learningRate,
real    momentum,
bool    verbose
[virtual]
 

Trains the network with data from the given TrainingSet using the backpropagation algorithm.

Parameters:
T  The TrainingSet containing input/desired-output vector pairs
epochs  The number of epochs to train the network. An epoch is a single iteration through all input/desired-output vector pairs in T.
learningRate  The learning rate to be used for weight updation
momentum  The momentum factor to be used during weight updation
verbose  If true, prints the current epoch number onto stdout, if false no such status information is given.

virtual void annie::MultiLayerNetwork::train TrainingSet   T,
int    epochs,
real    learningRate,
real    momentum = 0.0
[virtual]
 

Trains the network with data from the given TrainingSet using the backpropagation algorithm.

Parameters:
T  The TrainingSet containing input/desired-output vector pairs
epochs  The number of epochs to train the network. An epoch is a single iteration through all input/desired-output vector pairs in T.
learningRate  The learning rate to be used for weight updation
momentum  The momentum factor to be used during weight updation. 0 by default.


Member Data Documentation

std::vector<Layer *> annie::MultiLayerNetwork::_layers [protected]
 

The layers.

int annie::MultiLayerNetwork::_nLayers [protected]
 

Number of layers in the network. If you derive your own network from this class, the onus of keeping _nLayers consistent lies on you!


The documentation for this class was generated from the following file:
Generated on Wed Apr 23 10:42:36 2003 for BioFilter by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002