1 / 22
文档名称:

BP算法程序C语言实现.doc

格式:doc   大小:21KB   页数:22页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

BP算法程序C语言实现.doc

上传人:wz_198614 2017/6/17 文件大小:21 KB

下载得到文件列表

BP算法程序C语言实现.doc

相关文档

文档介绍

文档介绍:BP 算法程序 C 语言实现文件输入输出目录为: F:\BP\ 训练样本文件名: 值为: 11 -11 -110101 输出文件名为: ========================= #include "" #include "" #include "" #include "" #defi neN2 /*/ 学****样本个数*/ #define IN3 /*/ 输入层神经元数目*/ #define HN 3 /*/ 隐层神经元数目*/ #define ON 2 /*/ 输出层神经元数目*/ #define Z 20 /* 旧权值保存, 每次 study 的权值都保存下来*/ double P[IN]; /* 单个样本输入数据*/ double T[ON]; /* 单个样本输出数据*/ double W[HN][IN]; /*/ 输入层至隐层权值*/ dou ble V[ON][HN]; /*/ 隐层至输出层权值*/ double X[HN]; /*/ 隐层的输入*/ double Y[ON]; /*/ 输出层的输入*/ double H[HN]; /*/ 隐层的输出*/ double O[ON]; /*/ 输出层的输出*/ double YU_HN[HN]; /*/ 隐层的阈值*/ double YU_ON[ON]; /*/ 输出层的阈值*/ double err m[N]; /*/ 第m 个样本的总误差*/ d ouble a; /*/ 输出层至隐层的学****效率*/ double b; /*/ 隐层至输入层学****效率*/ double alpha; /*/ 动量因子,改进型 bp 算法使用*/ double d err[ON]; FILE *fp; /* 定义一个放学****样本的结构*/ struct { double input[IN]; double teach[ON]; }Study_Data[N]; /* 改进型 bp 算法用来保存每次计算的权值*/ struct { double old_W[HN][IN]; double old_V[ON][HN]; }Old_WV[Z]; 显示开始界面 int Start_Show() { clrscr(); printf("\n ***********************\n"); printf(" * e to use *\n"); printf(" * this program of *\n"); printf(" * calculating the BP *\n"); printf(" * model! *\n"); printf(" * Happy every day! *\n"); printf(" ***********************\n"); printf("\n\n Before starting, please read the follows carefully:\n\n"); printf(" ensure the Path of the ' '() is \n correct, like 'F:\BP\ '!\n"); printf(" calculating results will be saved in the Path of 'F:\\BP\\'!\n"); printf(" program will load 10 datas when running from 'F:\\BP\\ '!\n"); printf(" program of BP can study itself for no more than 30000 times.\n And surpassing the number, the program will be ended by itself in\n preventing running infinitely because of error!\n"); printf("\n\n\n"); printf("Now press any key to start...\n"); getch(); getch(); clrscr(); } 显示结束界面 int End_Show() { printf("\n\n---------------------------------------------------\n"); pr