home *** CD-ROM | disk | FTP | other *** search
/ Collection of Education / collectionofeducationcarat1997.iso / COMPUSCI / NNUTL101.ZIP / NNWHERE / NNWHERE.C < prev    next >
C/C++ Source or Header  |  1993-07-30  |  3KB  |  66 lines

  1. /*--------------------------------------------------------------------------*
  2.  * Gregory Stevens                                                   7/5/93 *
  3.  *                               NNWHERE.C                                  *
  4.  *                                                                          *
  5.  *   This is a program to be used with the nn*.c series for implementing    *
  6.  * the "what" feature detector algorithm described in the paper called      *
  7.  * "Why are What and Where Processed By Separate Cortical Visual Systems?"  *
  8.  * by J.G. Rueckl and Kyle R. Cave.  The following constant settings must   *
  9.  * be made:                                                                 *
  10.  *      NNPARAMS.C : INPUT_LAYER_SIZE   25    (the retina: 5x5)             *
  11.  *                   OUTPUT_LAYER_SIZE  9     (9 possible positions)        *
  12.  *                   NUM_HIDDEN_LAYERS  0                                   *
  13.  *                   HL_SIZE_1          0     (this can be changed)         *
  14.  *                                                                          *
  15.  *      NNINPUTS.C : NUM_PATTERNS  72         (8 patterns in 9 positions)++ *
  16.  *                                                                          *
  17.  *      NNSTRUCT.C : InitNet()  ...should set output nodes as logistic...   *
  18.  *                                                                          *
  19.  *      NNBKPROP.C : EPSILON 0.25  (recommended...this is what I used)      *
  20.  *                                                                          *
  21.  *--------------------------------------------------------------------------*/
  22. #include "nnbkprop.c"                /* to chain it to the nn*.c utilities  */
  23. #include <math.h>                    /* for the exp() for logistic units    */
  24.  
  25. #define NUM_ITS 100                  /* iterations before it stops          */
  26.  
  27. /*  MAIN PROGRAM  */
  28. void main()
  29. {
  30.   int Pattern;                         /* for looping through patterns   */
  31.   int Layer;                           /* for looping through layers     */
  32.   int LCV;                             /* for looping training sets      */
  33.   NNETtype Net;
  34.   PATTERNtype InPatterns, OutPattern;
  35.  
  36.   Net = InitNet( NUMNODES );            /* initializes the network        */
  37.   InPatterns = InitInPatterns(0);       /* loads input patterns from file */
  38.   OutPattern = InitOutPatterns();       /* loads output patterns from file*/
  39.  
  40.   for (LCV=0; (LCV < NUM_ITS); ++LCV)   /* loop through a training set    */
  41.     {
  42.       for (Pattern=0; (Pattern<NUM_PATTERNS); ++Pattern)
  43.          {
  44.             /* FORWARD PROPAGATION */
  45.             Net = UpDateInputAct( InPatterns, Pattern, Net );
  46.             for (Layer=1; (Layer<NUMLAYERS); ++Layer)
  47.               {
  48.                  Net = UpDateLayerAct( Net, Layer );
  49.               }
  50.  
  51.             /* OUTPUT PRINTS */
  52.             printf( "Pat: %d  ", Pattern );
  53.             printf( "Itr: %d", LCV );
  54.             printf( "\n" );
  55.             DisplayLayer( Net, 0, 5 ); /* display input layer  */
  56.             printf( "\n" );
  57.             DisplayLayer( Net, 1, 9 ); /* display output layer */
  58.             printf( "\n" );
  59.             if (LCV>90) getc(stdin);
  60.  
  61.             /* BACKWARD PROPAGATION */
  62.             Net = UpDateWeightandThresh( Net, OutPattern, Pattern );
  63.          }
  64.     }
  65. }
  66.