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

The Class CMul2L

This class is a representation of the proposed architecture. It consists of an object of class CMlayer used to implement the input layer and an object of class CBackPro used as the decision network. An object of class CData is used to handle the file access.

To create the modular neural network two constructors are offered. One is using a set of parameters to initialize the network, the other one loads the description from file. There is also a method to store the modular neural network on disk.

// the constructor with parameters
CMul2L::CMul2L( int no_u_inps,     // number of user inputs
                int no_cl,         // number of classes
                TNetDef *netL1,    // modules used in the input layer
                TNetDef *net_m,    // the decision module
                char *logfile = "multi.log",// the log file
                int mapping = RND_MAPPING,  // mapping: inputs-modules
                TOutRep out_rep = small);   // the representation of the
                                            // classes in the first layer

// the constructor from file
// method to set up the modular network according to the description file
CMul2L::CMul2L( char *filename,               // the description file
                char *dirname = "net_dir",    // the sub directory
                char *logfile = "multi.log"); // the log file

// function to store the network
int CMul2L::StoreNet( char *filename ,      // the main description file
                      char *dirname = "net_dir");// the directory

Two types of interfaces are provide by the class: a text-file based interface and a low-level interface. The file based interface offers methods to deal with a whole data file, such as train the network on a file, test the network on a file, or calculate the output for a given file.

// train the whole network on a data file
void CMul2L::Train(char *datafile,    // the data file
                   int maxStep_1,     // max of steps in input layer
                   double maxError_I, // max accep. error in input layer
                   int maxStep_m,     // max of steps in decision net
                   double maxError_D, // max accep. error in decision net
                   char *err_file_I = "input.err" ,  // error file name
                   char *err_file_D = "decision.err",// error file name
                   double eta=1,      // learning constant
                   double alpha = 0); // momentum

// test the performance of the network on a data file
//Returns the performance in percent (0..100%)
double CMul2L::Test(char *filename, // the data file
                    double diff =0.01, // the required difference between
                                       // winner and runner-up
                    int displ = 0);    // if displ >= 1 each result is
                                       // printed on the screen


// calculate the output for given input data in a file
void CMul2L::Work(char *infile,  // the input data
                  char *outfile, // the output file
                  int datefiletype =1, // the type of the data file
                                       // 0 = long    ( 1 0 1 0 : 1 ;)
                                       // 1 = short   ( 1 0 1 0 ;)
                  int displ = 0, // if displ > 0 each result is
                                 // printed on the screen
                  double diff = 0.01,  // the required difference between
                                       // winner and runner-up
                  int o_mode = 1);     // output mode 0= class only
                                       //             1= vector and class

The low-level interface allows working with single vectors. Explicit functions to calculate the results for a given input vector are provided. To learn single vectors methods in the input layer or in the decision network must be called.

// calculate the response for an input vector (the vector)
// returns the calculated output vector
TVector CMul2L::Apply( TVector resV,  // allocated result vector
                       TVector inV ); // input vector

// calculate the class number for an input vector
// Returns the class number or -1 if the difference
// between the winner and the runner-up is smaller than diff
int CMul2L::Detect(TVector inV,         // input vector
                   float diff = 0.01);  // the wanted difference


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

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