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

  1. /*-----------------------------------------------------------------------*
  2.  * Greg Stevens                                                  6/24/93 *
  3.  *                               nndisply.c                              *
  4.  *                                             [file 4 in a series of 6] *
  5.  *                                                                       *
  6.  *  This file contains a series of functions for displaying different    *
  7.  * values for nodes and weights in the network on the screen.            *
  8.  *                                                                       *
  9.  *  This file assumes the following declared in nnstruct:                *
  10.  *                               NUMNODES[]  number nodes in each layer  *
  11.  *                                                                       *
  12.  *                                                                       *
  13.  *-----------------------------------------------------------------------*/
  14. #include "nnstruct.c"                 /* for access to net information   */
  15. #include "stdio.h"                    /* for printf function             */
  16.  
  17. /* Function Display Layer displays layer Layer of net N formatted to width */
  18. /* W, where W is a number of nodes.                                        */
  19.  
  20. /* prototype for function */
  21. void DisplayLayer( NNETtype N, int Layer, int W );
  22.  
  23.  
  24. /* function definition */
  25. void DisplayLayer( NNETtype N, int Layer, int W )
  26. {
  27.    int u;                             /* looping variable for units      */
  28.  
  29.  
  30.    if (Layer==0)                      /* tags which layer is outputted   */
  31.      printf( " I:" );
  32.    else if (Layer==(NUMLAYERS-1))
  33.      printf( " O:" );
  34.    else
  35.      printf( "H%d:", Layer );
  36.  
  37.  
  38.    for (u=0; (u<NUMNODES[Layer]); ++u)             /* show activations   */
  39.      {
  40.        printf( "%6.2f", N.unit[Layer][u].state );
  41.        if (  (((u+1) % W)==0)  && ((u+1)!=NUMNODES[Layer])  )
  42.          printf( "\n   " );
  43.      }
  44. }