home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 11 Learning / 08 Manslow / CMLP.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  2.6 KB  |  84 lines

  1. //Tanks
  2. //Copyright John Manslow
  3. //29/09/2001
  4.  
  5. #ifndef _CMLP_
  6. #define _CMLP_
  7.  
  8. class CMLP
  9. {
  10. public:
  11.     CMLP(
  12.         const unsigned long,        //Number of inputs
  13.         const unsigned long,        //Number of hidden neurons
  14.         const unsigned long            //Number of outputs
  15.         );
  16.  
  17.     ~CMLP();
  18.  
  19.     void Reset(void);    //Used to reset the perturbation search and set the 
  20.                                 //network's weights to random values
  21.  
  22.     //This function performs one step in the perturbation search that allows the network
  23.     //to learn. The function is passed the quantity and location of the exemplar data
  24.     //and returns a measure of the network's current performance
  25.     double dTrainingStep(
  26.         const unsigned long,        //The number of samples in the exemplar data
  27.         double ** const,            //A pointer to the array of input samples
  28.         double ** const                //A pointer to the array of target outputs
  29.         );
  30.  
  31.     //Returns a pointer to an array containing the network outputs computed in response
  32.     //to the inputs provided
  33.     double *pdGetOutputs(
  34.         const double * const        //A pointer to an array of inputs
  35.         );
  36.  
  37.     //Returns the current performance of the network on the exemplar data. Is computed
  38.     //in dTrainingStep
  39.     double dGetPerformance(void);
  40.  
  41.     //Computes the performance of the network on the data set indicated in the function's
  42.     //parameters. Used internally. Should only be called from outside the class if
  43.     //the network's performance on a data set different to that passed to dTrainingStep is
  44.     //required.
  45.     double dGetPerformance(
  46.         const unsigned long,        //The number of samples in the data set
  47.         double** const,                //A pointer to the array of inputs
  48.         double** const                //A pointer to the array of target outputs
  49.         );
  50.  
  51.     void AllocateMemory(void);        //Functions used to allocate and deallocate memory
  52.     void DeallocateMemory(void);    //for the network structure
  53.  
  54.     int Save(const char * const);    //Used to load and save the network
  55.     int Load(const char * const);
  56.  
  57. private:
  58.     //These variables contain information about the network's structure
  59.     unsigned long ulNumberOfInputs;
  60.     unsigned long ulNumberOfHiddenNodes;
  61.     unsigned long ulNumberOfOutputs;
  62.  
  63.     //This is the step size currently used in the perturbation search
  64.     double dStepSize;
  65.  
  66.     //The performance of the network measured during the dTrainingStep function
  67.     double dBestError;
  68.  
  69.     //Pointers to the network's weights
  70.     double **ppdwih;
  71.     double **ppdwho;
  72.  
  73.     //Pointers to the best weights found during learning
  74.     double **ppdBestwih;
  75.     double **ppdBestwho;
  76.  
  77.     //Used to store the time and date when training started
  78.     char *pTrainingStartTime;
  79.     char *pTrainingStartDate;
  80. };
  81.  
  82. #endif
  83.  
  84.