c 语言编 bp 算法及使用说明
训练样本数据文件 sample.txt 输入格式:(单样本对)
(x1,x2,x3....xh,d1,d2,d3,...dj)
测试样本数据输入:(从键盘输入)
x1,x2,x3...xh
屏幕输出:y1,y2,y3...yj
在确定网络结构以后,即可确定(输入层)nh,(隐层)ni,(输出层)nj,(样本容量)nk
每次使用之前请修改网络结构数据。
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
#define nh 4
#define ni 9
#define nj 3
#define nk 30
#define nr 0.85/*学习效率*/
#define EPS 0.00001
float x[nk][nh],d[nk][nj],whi[nh][ni],wij[ni][nj],thi[ni],thj[nj];