home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / AI-90-10.ZIP / NEURAL.CPP < prev    next >
C/C++ Source or Header  |  1990-10-01  |  1KB  |  54 lines

  1. #include <fstream.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4. #include <time.h>
  5. #include "neural.hpp"
  6.  
  7. int main(int argc, char** argv)
  8. {
  9.     if(!argc == 2)
  10.     {
  11.         cerr<<"USAGE: NEURAL infile\n";
  12.         exit(1);
  13.     }
  14.     Network net;
  15.     if(net.trainingFile(argv[1]) == false)
  16.     {
  17.         cerr<<"Error in initializing net\n";
  18.         exit(2);
  19.     }
  20. #ifdef DISPLAY_YES
  21.     CLEAR_SCREEN();
  22. #endif
  23.     randomize();
  24.     time_t startTime;
  25.     time(&startTime);
  26.     for(;;){
  27.         net.forwardPass();
  28.         net.backwardProp();
  29.         net.displayDiff();
  30.         if(net.atEpochEnd())
  31.         {
  32.             if(kbhit())
  33.                 break;
  34.             if(net.trained())
  35.                 break;
  36.                 net.displayTotalError();
  37.             net.zeroTotalError();
  38. #ifdef DISPLAY_YES
  39.                   CURSOR_GOTO(1,1);
  40. #endif
  41.         }
  42.     }
  43.     time_t endTime;
  44.     time(&endTime);
  45.     net.allForward();
  46.     cin.get();
  47.     net.display();
  48.     unsigned long elapsed = (unsigned) endTime - (unsigned) startTime;
  49.     net.displayPerformance(elapsed);
  50. }
  51.  
  52.  
  53.     
  54.