资源简介
Vc++的程序,简单的bp算法实现数据分类。
代码片段和文件信息
#include
#include
#include
#include
using namespace std;
#define NH 2
#define STEP 1
double **ppData; //data
double *pY; //std result
double *pOut; //ouput
double **ppIn; //
double **WeightIn; //hidden note weight
double *WeightOut; //output note weight
double **DWin; //last time hidden note weight
double *DWout; //last time output note weight
double Con_b[NH+1];
int DataNum; // data number
int Dimension; // dimension
double Threshhold; // sheld
double Sigmoid(double x)
{
return 1.0/(1+exp(-x));
}
double DotProduct(double* vec1double *vec2int dim)
{
double result=0.0;
for(int i=0;i {
result+=vec1[i]*vec2[i];
}
return result;
}
//compute the output each step
void ComputeOutput()
{
for(int i=0;i {
for(int j=0;j {
double dp=DotProduct(ppData[i]WeightIn[j]Dimension);
dp+=Con_b[j];
ppIn[i][j]=Sigmoid(dp);
}
}
for(int i=0;i {
double dp=DotProduct(ppIn[i]WeightOutNH);
dp+=Con_b[NH];
pOut[i]=Sigmoid(dp);
}
}
//update weights matrix
void UpdateW()
{
double DegreeIn[NH];
double DegreeOut=0;
for(int i=0;i {
for(int j=0;j {
DWin[i][j]=0;
}
DWout[i]=0;
}
for(int i=0;i {
DegreeOut=pOut[i]*(1-pOut[i])*(pY[i]-pOut[i]);
for(int h=0;h {
DegreeIn[h]=ppIn[i][h]*(1-ppIn[i][h])*WeightOut[h]*DegreeOut;
Con_b[h]+=STEP*DegreeIn[h];
}
Con_b[NH]+=STEP*DegreeOut;
for(int j=0;j {
DWout[j]+=STEP*DegreeOut*ppIn[i][j];
//cout< }
for(int x=0;x {
for(int y=0;y {
DWin[x][y]+=STEP*DegreeIn[x]*ppData[i][y];
}
}
}
for(int k=0;k {
for(int j=0;j {
WeightIn[k][j]+=DWin[k][j];
//cout< }
WeightOut[k]+=DWout[k];
//cout< }
//cout< }
double GetError()
{
double e=0.0;
for(int i=0;i {
e+=(pY[i]-pOut[i])*(pY[i]-pOut[i])/2;
}
return e;
}
void Train()
{
double error=100000;
int t=0;
do{
UpdateW();
ComputeOutput();
error=GetError();
//
t++;
}while(error>Threshhold&&t<2000);
cout< for(int i = 0;i < DataNum;i ++)
{
cout< }
cout< }
double *GetResult(double thresh)
{
for(int i=0;i {
for(int j=0;j {
double dp=DotProduct(ppData[i]WeightIn[j]Dimension);
dp+=Con_b[j];
ppIn[i][j]=Sigmoid(dp);
}
}
for(int i=0;i {
double dp=DotProduct(ppIn[i]WeightOutNH);
dp+=Con_b[NH];
pY[i]=Sigmoid(dp);
if(pY[i]>thresh)
{
pY[i]=1;
}
else pY[i]=0;
}
return pY;
}
bool Init(double **datadouble *yint numint dimdo属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6369 2009-11-28 16:05 Backpropagation\backpropagation.cpp
文件 25639 2009-11-28 16:04 Backpropagation\readme.docx
目录 0 2009-11-28 16:05 Backpropagation
----------- --------- ---------- ----- ----
32008 3
- 上一篇:c++ HTTP协议库 httplib
- 下一篇:基于vc++的波形显示源码
相关资源
- BP神经网络C语言工程当前最终版
- 可以在单片机上计算的BP神经网络C语
- BP算法的C++实现
- 百度地图二次开发汇总
- 基于VC++的人脸定位系统
- BP神经网络实现人脸识别包含软件源码
- 人工神经网络之BP网络模拟三角函数
- 车牌识别 openCV mfc BP神经网络
- vcMfcUsbPort完整上位机源码
- 基于C++版本的Bp神经网络,数据拟合,
- 用于人脸识别的lbp算法C++源码
- C++ bp神经网络算法
- VS工程中zlib.h、png.h相关文件
- C++builder创建bpl库并调用
- BP神经网络的c++实现
- 基于BP神经网络的简单字符识别算法自
- BP算法实现圆迹SAR点目标仿真C++语言
- BP三层神经网络实现C++代码注释详细
- libpng资源包
- BP神经网络鸢尾花分类C++代码
- 基于LIBPCAP的网络流量实时采集与信息
- 基于C语言的BPSK
- 多元 多进制 NB LDPC BP QSPA译码 decoder
- WebPage.h和WebPage.cpp
- BP神经网络VC++实现
- bp车牌识别源代码
- C++实现的BP神经网络算法实现奇偶检验
- BP算法程序实现包括matlab、C语言、C
-
C++中使用CWebPage调用ja
vasc ript - C++代码提取LBP特征
川公网安备 51152502000135号
评论
共有 条评论