next up previous contents
Next: The Class CMLayer Up: The Neural Network Library Previous: The Class CLayer

The Class CBackPro

This class implements a Backpropagation module. Objects of this type can be used as building bricks in a modular neural network. The interfaces to the most important methods are shown below.

Two constructors are provided. The first creates a network from a set of parameters; in this form the number of neurons in the last used layer must be equal to the number of outputs; the weights are initialized randomly. The other constructor load a module from file. The variables and weights are set according to the values in the file. There is also a method to store the module in a file.

/* Constructor using parameters:
CBackPro::CBackPro(int no_inputs,  // no of inputs
                   int no_layers,  // no of layers
                   double lambda,  // lambda value
                   TFunction func, // transfer function
                   char *logfile,  // name of the log file
                                   // use NO_LOG for skipping the log
                   int neuronL0,   // no of neurons in layer 0
                   int neuronL1,   // no of neurons in layer 1
                   int neuronL2=0,
                   int neuronL3=0, // no of neurons in the following
                   int neuronL4=0, // layers (default = 0)
                   int neuronL5=0);

/* Constructor to load a stored network file
   The first parameter is the name of file which contains a description
   of a network (with or without weights). The net description files
   might be typed in by using any editor or generated by the method
   CBackPro::StoreNet(...) . The second parameter is the
   name of the logfile (NO_LOG makes no logfile).             */
CBackPro::CBackPro(char *filename,      // net description file
                   char *logfile);      // name of the logfile

// Store the network in a file
void CBackPro::StoreNet(char *filename);

The module offers methods to learn vector pairs using the BP algorithm and to calculate the response for an input vector. A method to reset the weights in a given range is provided.

// Learn one vector for which the result is known
// Returns the propagated error
double CBackPro::Learn(TVector inpV,     // the vector to learn
                       TVector tarV,     // the desired result
                       double eta,       // the learning constant
                       double alpha);    // the momentum

// calculate the output for a given input
// Returns the calculated response
TVector CBackPro::Apply(TVector outV,   // the allocated result vector
                        TVector inpV);  // the input vector

// Reset the weights to a random value in a range between min and max
void CBackPro::ResetWeights(double min=MIN_RND, double max=MAX_RND);

next up previous contents
Next: The Class CMLayer Up: The Neural Network Library Previous: The Class CLayer

Albrecht Schmidt
Mit Okt 4 16:45:34 CEST 2000