div class="twikiTopBar">

Chair for Computer Aided Medical Procedures & Augmented Reality
Lehrstuhl für Informatikanwendungen in der Medizin & Augmented Reality

NeuralNet Class Reference


Public Member Functions

 NeuralNet (int inputNeurons, int hiddenNeurons, int outputNeurons, double learningRate)
 ~NeuralNet ()
void addTrainingdata (double *input, double *output)
int getTrainingsetSize ()
void getTrainingdata (int n, double *input, double *output)
void train (int epochs=0)
void getOutput (double *input, double *output)
double getError ()

Private Member Functions

void calculateActivations ()

Private Attributes

int m_inputNeurons
 Number of input neurons.
int m_hiddenNeurons
 Number of hidden neurons.
int m_outputNeurons
 Number of output neurons.
double m_learningRate
 Learning rate.
double ** m_w1
 Weight matrix of first layer ([1..hiddenNeurons][0..inputNeurons]).
double ** m_w2
 Weight matrix of second layer ([1..outputNeurons][0..hiddenNeurons]).
double * m_x
 Input vector of input neurons ([0..inputNeurons]).
double * m_a
 Input vector of hidden neurons ([1..hiddenNeurons]).
double * m_z
 Output vector of hidden neurons ([0..hiddenNeurons]).
double * m_y
 Output vector of output neurons ([1..outputNeurons]).
vector< double * > m_trainingInput
 Input vectors (including bias, i.e. [0..inputNeurons]) of the training set.
vector< double * > m_trainingOutput
 Output vectors (including "dummy" [0], i.e. [0..outputNeurons]) of the training set.

Detailed Description

Neural net class

This class implements a feedforward neural net with one layer of hidden neurons and arbitrary numbers of input, hidden and output neurons. It is trained using the standard backpropagation algorithm.

Definition at line 24 of file NeuralNet.h.


Constructor & Destructor Documentation

NeuralNet::NeuralNet int  inputNeurons,
int  hiddenNeurons,
int  outputNeurons,
double  learningRate
 

Constructor

Parameters:
inputNeurons Number of input neurons
hiddenNeurons Number of hidden neurons
outputNeurons Number of output neurons
learningRate Learning rate

Definition at line 17 of file NeuralNet.cpp.

NeuralNet::~NeuralNet  ) 
 

Destructor

Definition at line 69 of file NeuralNet.cpp.


Member Function Documentation

void NeuralNet::addTrainingdata double *  input,
double *  output
 

Add values to the training set

Parameters:
input Pointer to array [0..inputNeurons-1] containing the input vector
output Pointer to array [0..outputNeurons-1] containing the corresponding output vector

Definition at line 93 of file NeuralNet.cpp.

void NeuralNet::calculateActivations  )  [private]
 

Calculate the activations (input of the hidden neurons, output of hidden and output neurons) for the current input vector x

Definition at line 278 of file NeuralNet.cpp.

double NeuralNet::getError  ) 
 

Calculate the value of the error function given the current training set and weights

Returns:
error

Definition at line 253 of file NeuralNet.cpp.

void NeuralNet::getOutput double *  input,
double *  output
 

Retrieve the net output given the current weights and an input vector

Parameters:
input Pointer to array [0..inputNeurons-1] containing the input vector
output Pointer to array [0..outputNeurons-1] where the output vector will be stored

Definition at line 239 of file NeuralNet.cpp.

void NeuralNet::getTrainingdata int  n,
double *  input,
double *  output
 

Retrieve an input and output vector out of the training set

Parameters:
n Number (index) of the vectors (between 0 and getTrainingsetSize()-1)
input Pointer to array [0..inputNeurons-1] where the input vector will be stored
output Pointer to array [0..outputNeurons-1] where the output vector will be stored

Definition at line 115 of file NeuralNet.cpp.

int NeuralNet::getTrainingsetSize  ) 
 

Retrieve the size of the current training set

Returns:
Size of training set

Definition at line 110 of file NeuralNet.cpp.

void NeuralNet::train int  epochs = 0  ) 
 

Train the net with the current training set

Parameters:
epochs Number of iterations (if 0, training will stop as soon as the error decreases less than 0.0001% per iteration)

Definition at line 126 of file NeuralNet.cpp.

NeuralNet Class Reference | generated on Sun Apr 29 02:01:10 2007 by Doxygen 1.4.1 for DWARF