nndisply.c

来自「基于MATLAB完成的神经网络源程序 大家」· C语言 代码 · 共 44 行

C
44
字号
/*-----------------------------------------------------------------------*
 * Greg Stevens                                                  6/24/93 *
 *                               nndisply.c                              *
 *                                             [file 4 in a series of 6] *
 *                                                                       *
 *  This file contains a series of functions for displaying different    *
 * values for nodes and weights in the network on the screen.            *
 *                                                                       *
 *  This file assumes the following declared in nnstruct:                *
 *                               NUMNODES[]  number nodes in each layer  *
 *                                                                       *
 *                                                                       *
 *-----------------------------------------------------------------------*/
#include "nnstruct.c"                 /* for access to net information   */
#include "stdio.h"                    /* for printf function             */

/* Function Display Layer displays layer Layer of net N formatted to width */
/* W, where W is a number of nodes.                                        */

/* prototype for function */
void DisplayLayer( NNETtype N, int Layer, int W );


/* function definition */
void DisplayLayer( NNETtype N, int Layer, int W )
{
   int u;                             /* looping variable for units      */


   if (Layer==0)                      /* tags which layer is outputted   */
     printf( " I:" );
   else if (Layer==(NUMLAYERS-1))
     printf( " O:" );
   else
     printf( "H%d:", Layer );


   for (u=0; (u<NUMNODES[Layer]); ++u)             /* show activations   */
     {
       printf( "%6.2f", N.unit[Layer][u].state );
       if (  (((u+1) % W)==0)  && ((u+1)!=NUMNODES[Layer])  )
         printf( "\n   " );
     }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?