电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

神经网络BP算法程序C语言

11页
  • 卖家[上传人]:re****.1
  • 文档编号:470355873
  • 上传时间:2023-03-13
  • 文档格式:DOC
  • 文档大小:35.01KB
  • / 11 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 1、神经网络BP算法(C程序) 文件输入输出目录为:F:BP训练样本文件名:训练样本.txt值为:1 1 -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 PIN; /*单个样本输入数据*/double TON; /*单个样本输出数据*/double WHNIN; /*/输入层至隐层权值*/double VONHN; /*/隐层至输出层权值*/double XHN; /*/隐层的输入*/double YON; /*/输出层的输入*/double HHN; /*/隐层的输出*/double OON; /*/输出层的输出*/double YU_HNHN; /*

      2、/隐层的阈值*/double YU_ONON; /*/输出层的阈值*/double err mN; /*/第m个样本的总误差*/double a; /*/输出层至隐层的学习效率*/double b; /*/隐层至输入层学习效率*/double alpha; /*/动量因子,改进型bp算法使用*/double d errON;FILE *fp;/*定义一个放学习样本的结构*/struct double inputIN;double teachON;Study_DataN;/*改进型bp算法用来保存每次计算的权值*/struct double old_WHNIN;double old_VONHN;Old_WVZ;显示开始界面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);prin

      3、tf( *n);printf(nn Before starting, please read the follows carefully:nn);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 inn preventing running infinitely beca

      4、use of error!n);printf(nnn);printf(Now press any key to start.n);getch();getch();clrscr();显示结束界面int End_Show()printf(nn-n);printf(The program has reached the end successfully!nn Press any key to exit!nn);printf(n *n);printf( * This is the end *n);printf( * of the program which*n);printf( * can calculate the BP*n);printf( * model! *n);printf( *n);printf( * Thanks for using! *n);printf( * Happy every day! *n);printf( *n);getch();exit(0);获取训练样本GetTrainingData() /*OK*/ int m,i,j; int datr;if(fp=fope

      5、n(f:bp训练样本.txt,r)=NULL) /*读取训练样本*/ printf(Cannot open file and strike any key exit!); getch(); exit(1); m=0;i=0;j=0;while(fscanf(fp,%d,&datr)!=EOF) j+; if(j=(N*IN) /*N为学习样本个数;IN为输入层神经元数目*/ if(iIN) Study_Datam.inputi=datr; /*printf(nthe Study_Datat%d.input%d=%fn,m,i,Study_Datam.inputi);getch();*/ /*use to check the loaded training datas*/ if(m=(N-1)&i=(IN-1) m=0; i=-1; if(i=(IN-1) m+; i=-1; else if(N*IN)J&J=(N*(IN+ON) if(iON) Study_Datam.teachi=datr; /*printf(nThe Study_Data%d.teach%d=%f,m,i,Stud

      6、y_Datam.teachi);getch();*/ /*use to check the loaded training datas*/ if(m=(N-1)&i=(ON-1) printf(n); if(i=(ON-1) m+; i=-1; i+;fclose(fp);printf(nThere are %d datats that have been loaded successfully!n,j);/*show the data which has been loaded!*/printf(nShow the data which has been loaded as follows:n);for(m=0;mN;M+)for(i=0;iIN;I+) printf(nStudy_Data%d.input%d=%f,m,i,Study_Datam.inputi); for(j=0;jON;J+) printf(nStudy_Data%d.teach%d=%f,m,j,Study_Datam.teachj); printf(nnPress any key to start calculating.);getch();return 1;/*/*/*初始化权、阈值子程序*/*/*/initial()int i;int ii;int j;int jj;int k;int kk;/*隐层权、阈值初始化*/for(i=0;iHN;i+) for(j=1;jIN;j+) Wij=(double)(rand()/32767.0)*2-1); /*初始化输入层到隐层的权值,随机模拟0 和 1 -1 */ printf(w%d%d=%fn,i,j,Wij); for(ii=0;iiON;II+) for(jj=0;jjHN;JJ+) Viijj= (double)(rand()/32767.0)*2-1); /*初始化隐层到输出层的权值

      《神经网络BP算法程序C语言》由会员re****.1分享,可在线阅读,更多相关《神经网络BP算法程序C语言》请在金锄头文库上搜索。

      点击阅读更多内容
    最新标签
    监控施工 信息化课堂中的合作学习结业作业七年级语文 发车时刻表 长途客运 入党志愿书填写模板精品 庆祝建党101周年多体裁诗歌朗诵素材汇编10篇唯一微庆祝 智能家居系统本科论文 心得感悟 雁楠中学 20230513224122 2022 公安主题党日 部编版四年级第三单元综合性学习课件 机关事务中心2022年全面依法治区工作总结及来年工作安排 入党积极分子自我推荐 世界水日ppt 关于构建更高水平的全民健身公共服务体系的意见 空气单元分析 哈里德课件 2022年乡村振兴驻村工作计划 空气教材分析 五年级下册科学教材分析 退役军人事务局季度工作总结 集装箱房合同 2021年财务报表 2022年继续教育公需课 2022年公需课 2022年日历每月一张 名词性从句在写作中的应用 局域网技术与局域网组建 施工网格 薪资体系 运维实施方案 硫酸安全技术 柔韧训练 既有居住建筑节能改造技术规程 建筑工地疫情防控 大型工程技术风险 磷酸二氢钾 2022年小学三年级语文下册教学总结例文 少儿美术-小花 2022年环保倡议书模板六篇 2022年监理辞职报告精选 2022年畅想未来记叙文精品 企业信息化建设与管理课程实验指导书范本 草房子读后感-第1篇 小数乘整数教学PPT课件人教版五年级数学上册 2022年教师个人工作计划范本-工作计划 国学小名士经典诵读电视大赛观后感诵读经典传承美德 医疗质量管理制度 2
    关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
    手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
    ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.