📄 bpnet.cpp
字号:
// BPNet.cpp: implementation of the CBPNet class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "bp.h"
#include "BPNet.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBPNet::CBPNet()
{
bSuccess=false;
for (int i=0;i<10;i++)
{
for (int j=0;j<10;j++)
{
if (i==j)
{
t[i][j]=1;
}
else
t[i][j]=0;
}
}
}
CBPNet::~CBPNet()
{
}
void CBPNet::InitWeight()
{
int i,j;
//伪随机种子
srand((unsigned)time( NULL ) );
for(i=0;i<M1;i++)
{
for(j=0;j<P;j++)
{
float rnd;
rnd=(rand()%1000)/10000.0;
hide1_w[i][j]=rnd;//权值初始化。
}
}
/* for(i=0;i<M2;i++)
{
for(j=0;j<M3;j++)
{
float rnd;
rnd=(rand()%100)/10000.0;
hide2_w[i][j]=rnd;//权值初始化。
}
}
for(i=0;i<M1;i++)
{
for(j=0;j<M2;j++)
{
float rnd;
rnd=(rand()%100)/10000.0;
hide1_w[i][j]=rnd;//权值初始化。
}
}*/
for(i=0;i<N;i++)
{
for(j=0;j<M1;j++)
{
float rnd;
rnd=(rand()%1000)/10000.0;
intoh_w[i][j]= rnd;//权值初始化。
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -