神经网络c语言程序算了一天,神经网络BP算程序C语言.doc

神经网络BP算程序C语言

神经网络BP算法(C程序)

文件输入输出目录为:F:\BP\

训练样本文件名:训练样本.txt

值为:

11 -1 1 -1 1 0 1 0 1

输出文件名为:阈值.txt??? 权值.txt

=========================

#include "stdlib.h"#include "math.h"#include "conio.h"#include "stdio.h"#define N 2 /*/学习样本个数*/#define IN 3 /*/输入层神经元数目*/#define HN 3 /*/隐层神经元数目*/#define ON 2 /*/输出层神经元数目*/#define Z 20 /*旧权值保存每次study的权值都保存下来*/double P[IN]; /*单个样本输入数据*/double T[ON]; /*单个样本数据*/double W[HN][IN]; /*/输入层至隐层权值*/double 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个样本的总误差*/double 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("?????????????????????? *??? Welcome 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("??? 1.Please ensure the Path of the '训练样本.txt'(xunlianyangben.txt) is \n correct, like 'F:\BP\训练样本.txt'!\n");printf("??? 2.The calculating results will be saved in the Path of 'F:\\BP\\'!\n");printf("??? 3.The program will load 10 datas when running from 'F:\\BP\\训练样本.txt'!\n");printf("??? 4.The 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("No

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值