📄 nnhebbln.c
字号:
/*-----------------------------------------------------------------------*
* Greg Stevens 6/24/93*
* NNHEBBLN.C *
* [file 6 in a series of 6] *
* *
* This file contains the functions for calculating the error and weight *
* changes for the Hebb rule for unsupervised learning. Defined *
* in this file are EPSILON, the weight change increment/coefficient, *
* and function that updates the weights [UpDateWeightandThresh()]. It *
* also contains code for a function called GetDerivs(), but this is to *
* be used in the function UpDateWeightsandDerivs(), not by a main *
* program. *
* *
*-----------------------------------------------------------------------*/
#include "nnloadin.c"
#define EPSILON 0.01 /* constant incrementation for weight change */
/* Function Prototype */
NNETtype UpDateWeightandThresh( NNETtype oldn );
/* Function Definition */
NNETtype UpDateWeightandThresh( NNETtype oldn )
{
NNETtype n;
int u,v;
int BIG = 0;
n = oldn;
for (u=0; (u<OUTPUT_LAYER_SIZE); ++u )
{
if (n.unit[1][u].state>0.0) /* increment weights of */
{ /* connex. btw. any co- */
for (v=0; (v<INPUT_LAYER_SIZE); ++v ) /* active nodes. */
{
if (n.unit[0][v].state>0.0)
n.unit[1][u].weights[v] += EPSILON;
if (n.unit[1][u].weights[v]>10.0)
BIG = 1;
}
}
}
if (BIG==1) /* if weights grew too */
{ /* much, scale all down */
for (u=0; (u<OUTPUT_LAYER_SIZE); ++u )
{
for (v=0; (v<INPUT_LAYER_SIZE); ++v )
{
n.unit[1][u].weights[v] = n.unit[1][u].weights[v] / 2.0;
}
}
}
return( n );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -