資源描述:
《改進(jìn)的BP神經(jīng)網(wǎng)絡(luò)算法(C語言源碼).doc》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、#include"stdio.h"#include"stdlib.h"#include"time.h"#include"math.h"/*********************************************inpoints為輸入神經(jīng)元個數(shù),可改變outpoints為輸出神經(jīng)元個數(shù)defaultpoints為隱層神經(jīng)元個數(shù)datagrough為樣本數(shù)據(jù)個數(shù)****************************************************以下數(shù)據(jù)定義可以修改*****/#defineA0#definea1#defineb1#definec
2、1#defineALFA0.85#defineBETA0.2//學(xué)習(xí)率0~1#defineTotal20000#defineinpoints9#defineoutpoints5#definedefaultpoints28#definedatagrough44#defineforecastdata4/**********定義所需變量********/doubleInpointData[datagrough][inpoints],OutpointData[datagrough][outpoints];/*輸入輸出數(shù)據(jù)*/doubleInpointData_MAX[inpoints
3、],InpointData_MIN[inpoints];/*每個因素最大數(shù)據(jù)*/doubleOutpointData_MAX[outpoints],OutpointData_MIN[outpoints];/*每個因素最小數(shù)據(jù)*/doublew[defaultpoints][inpoints],limen[defaultpoints],v[outpoints][defaultpoints];/*連接權(quán)值、閾值*/doubledlta_w[defaultpoints][inpoints],dlta_limen[defaultpoints],dlta_v[outpoints][de
4、faultpoints];/*連接權(quán)、閾值修正值*/doubledefaultOutpoint[defaultpoints],Outpoint_dp[outpoints],Outpoint_ep[datagrough];/**************************讀數(shù)據(jù)文件******************************/voidReadData(){FILE*fp1,*fp2;inti,j;if((fp1=fopen("D:\data\訓(xùn)練輸入.txt","r"))==NULL){printf("1cannotopenthefile");exi
5、t(0);}for(i=0;i6、/*****************************************************//*****************************************歸一化******************************************************/voidunitary(){inti,j;intk=0;for(j=0;j7、ta[0][j];InpointData_MIN[j]=InpointData[0][j];for(i=0;iInpointData[i][j])InpointData_MIN[j]=InpointData[i][j];}for(j=0;j