NeuralNetwork Class Reference

#include <NeuralNetwork.h>

List of all members.

Public Member Functions

 NeuralNetwork (const NeuralNetwork &network)
NeuralNetworkoperator= (const NeuralNetwork &network)
void ConstructNetworkFromFile (const char *file) throw (std::invalid_argument)
void DeserializeData (std::istream &strm)
void AddNeuronLevel (int numNeurons)
NeuronGetNeuron (int indx)
int GetNumNeurons () const
int GetNumInputNeurons () const
int GetNumOutputNeurons () const
int GetNumLevels () const
int GetNumNeuronsAtLevel (int level) const
TestData * GetTestData ()
void AddData (std::vector< double > &input, std::vector< double > &output, int index) throw (std::logic_error)
void DefineTrainingData (int inFeatures, int outFeatures, int numSamples)
void AddSampleData (std::vector< double > &input, std::vector< double > &output, int index) throw (std::logic_error)
int * GetConnectingNeurons (int indx) const
void ConnectNeuron (int neuronIndex, const std::vector< double > &weightVec, const std::vector< int > &neuronFromVec)
const NeuralNetworkBuilderGetBuilder () const
void FeedInput (const std::vector< double > &input, std::vector< double > &output)
void FeedInput (const double *input, double *output)
void FeedInput (const double *input, double *output, double *net_input)
bool DetectCycle ()
bool CalibrateWeights (double eeta, int maxIter, double minResidual, double &finalResidual)
void ClearNetwork ()


Detailed Description

Nneural network class This class holds the collection of neurons forming the network, activation (input) neurons and output neurons.It keeps all the connection details for neurons. A feed forward neural network is defined in terms of levels. Neurons at each level connect to/from neurons from adjacent levels only. The network is specified as follows: The network has iNumLevels number of levels (n) level 0: num_neurons_in_level_0 level 1: num_neurons_in_level_1 ... level n: num_neurons_in_level_n

The neurons are numbered from level 0 to level n. For example, level 0 will have neurons numbered 0 through num_neurons_in_level_0-1

The neuron connections are specified as: neuron_k : neuron_i neuron j neuron m This represents neuron numbered k to be connected to (receiving input from) neurons i, j and m. For feed forward neural networks, i,j,m must belong to previous level. The neural network is a forest.


Member Function Documentation

void NeuralNetwork::AddNeuronLevel int  numNeurons  ) 
 

Creates a neuron level comprising of numNeurons The neurons are assigned index number automatically.

void NeuralNetwork::AddSampleData std::vector< double > &  input,
std::vector< double > &  output,
int  index
throw (std::logic_error)
 

Add training data.

Parameters:
input,: vector containing input output: vector containing output index: index number of this sample data
Exceptions:
std::logic_error Thrown when DefineTrainingData is not invoked before calling this function.

void NeuralNetwork::ConnectNeuron int  neuronIndex,
const std::vector< double > &  weightVec,
const std::vector< int > &  neuronFromVec
 

specify the weights attached to a neuron and the neurons from which a particular neuron receives connections (inputs)

Parameters:
neuronIndex,: index of neuron weightVec: vector of weights neuronFromVec: vector of neuron indices that send an input to this vector. For input neurons (level 0 neurons), this argument contains indices from input Vec (from where the neuron gets its activation). It must have an equal number of elements as weightVec.

void NeuralNetwork::ConstructNetworkFromFile const char *  file  )  throw (std::invalid_argument)
 

Deserialize and construt the network from file throws invalid_argument exception if file could not be opened for reading.

void NeuralNetwork::DefineTrainingData int  inFeatures,
int  outFeatures,
int  numSamples
 

Create pData that contains the training data inFeatures: number of input features outFeatures: number of output features numSamples: number of samples in the data

bool NeuralNetwork::DetectCycle  ) 
 

A feed forward neural network does not have cycles This function can be use to check if cycles are present once the neural network is defined. Returns true if cycle is present, false otherwise

void NeuralNetwork::FeedInput const double *  input,
double *  output,
double *  net_input
 

Overloaded version when input is provided as pointer to array and output is given in array, and total input for each neuron is needed as an output from this function.

This function could have been merged with previous one by making last argument default to NULL, but that would make the fuction inefficient due to if check inside the for loop. Morover, this function is called frequently in any calibration.

The output array should have sufficient size (>= number of output neurons in network) If input across all samples is in form of one array, this function can be used by providing appropriate offset into the array (avoids copying) Apply input signal to the network. Returns the output in vector output containing network response to the input.

Parameters:
input,: array containing the input. This is copied to pInputVec. output: output array containing network response, one output for each output neuron (i.e. level n neuron). # of elements in array >= neurons in last level net_input: total input that gives neuron activation as activation = g(net_input)

void NeuralNetwork::FeedInput const double *  input,
double *  output
 

Overloaded version when input is provided as pointer to array and output is given in array. The output array should have sufficient size (>= number of output neurons in network) If input across all samples is in form of one array, this function can be used by providing appropriate offset into the array (avoids copying) Apply input signal to the network. Returns the output in vector output containing network response to the input.

Parameters:
input,: array containing the input. This is copied to pInputVec. output: output array containing network response, one output for each output neuron (i.e. level n neuron). # of elements in array >= neurons in last level

void NeuralNetwork::FeedInput const std::vector< double > &  input,
std::vector< double > &  output
 

Apply input signal to the network. Returns the output in vector output containing network response to the input.

Parameters:
input,: vector containing the input. This is copied to pInputVec. output: output vector containing network response, one output for each output neuron (i.e. level n neuron). # of elements added at the back of this vector = neurons in last level

Neuron* NeuralNetwork::GetNeuron int  indx  )  [inline]
 

Get a neuron added to the network by index (starting from 0)


The documentation for this class was generated from the following files:
Generated on Sun Aug 24 17:33:41 2008 by  doxygen 1.4.6