Setting up the backpropagation plugin

Sunday,May 25 ,2008

The neural network trainer as a standalone application works using plug in based system, in this case a DLL (Dynamic Link Library), which contains all functions used by the neural trainer.

I have not posted the neural trainer code so far, because it is still on process however I will post my old code of this project. This project is my first attempt so it will be difficult to understand to you. The program is written in C++ and compiled using Visual C++. First I am going to post and explain the main header of the library for backpropagation neural network.

First of all, I am going to explain all the variables and structures.

The main structure consists of three different structures linked together:
Structure NEURON:
The simplest element of the network, it contains all information of inputs, outputs delta weigths.
typedef struct
{

double *weight; //Weights of each input of the neuron
double *deltas; //Delta element
double output; //Ouput of the neuron
double gain; //Gain
double gainw; //weighted gain
}NEURON,*LPNEURON;
Structure LAYER
Represents a layer of neurons of the feed-forward neural network
typedef struct
{
LPNEURON *neuron;//Array of neurons of the layer
double *layerinput;//Array of inputs of the layer
int16 NumInputs;//Size of input array
int16 NumNeurons;//Size of neuron array
}LAYER,*LPLAYER;
Structure MLNN (multi layer neural network)
typedef struct
{
LPLAYER *layers;//Array of layers of the neural network
double *Outputs;// Array of outputs
int16 numofoutputs;//Size of output array
double *maininput;//The main input of the network(array)
int16 InputSize;//Size of the main input
int16 NumOfLayers;//Number of layers the network has
int16 NumOfInputs;//Size of the input array
int16 NumOfHiddens;//Number of hidden layers
}MLNN,*LPMLNN;

These three structure are the core of the network, they have all the information of the neural network. How it works? The program initializes all structures according to the user needs.

This how looks the rest of the file:
typedef struct //The file header to store the neural network information
{ UINT id;
UINT version;
}FILENETHEADER; bool UpdateLayerInputs(LPMLNN,int16); //Update the inputs of the next layer this is the main task of the back propagation neural network
double Random();//Generates a random number
//And at last our exported functions (MLNN_LIB stands for __declspec(dllexport) for visual C)
bool MLNN_LIB CALLBACK CreateNNetWork(LPMLNN *,int16,int16,int16,int16,int16);
bool MLNN_LIB CALLBACK DeleteNNetWork(LPMLNN *);
double MLNN_LIB CALLBACK TrainNNetWork(LPMLNN ,double *,double,double);
bool MLNN_LIB CALLBACK RunNNetWork(LPMLNN);
bool MLNN_LIB CALLBACK SaveTOFile(char *,LPMLNN);
bool MLNN_LIB CALLBACK LoadFromFile(char *,LPMLNN*);
bool MLNN_LIB CALLBACK GetNetInfo(char *);
bool MLNN_LIB CALLBACK GetNetTitle(char *);
bool MLNN_LIB CALLBACK SetInputs(LPMLNN,double*);

How we setup our backpropagation network? First we call CreateNNetwork which allocates memory for the network, then we proceed to set train our patterns by setting the inputs for the neural network, the function TraiNNetwork returns the error of the network.



Category Neural network trainer project

Comments (1)

Webmaster

I Really apologize for not posting the complete source code because I need to do some changes to it in order for being understandable.

Regards.

You may use html tags <a href="url">Your link</a>,<b></b>,<ul><li>.

Name:
Email(Optional):
URL(Optional):
Comment:
Are you human? if you are answer this simple question:
What color was Napolion's white horse?