資源描述:
《BP算法的C語言實(shí)現(xiàn).doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、終于搞定了,輸出結(jié)果完全正確,運(yùn)行訓(xùn)練次數(shù)竟然有幾萬次!汗!(適合普通BP算法和改進(jìn)型BP[帶緩沖項(xiàng)]算法)//訓(xùn)練樣本大概是這些(每組前三個(gè)為in樣本數(shù)據(jù)后面為out結(jié)果)://0000.9//0010.1//0100.1//0110.9//1000.1//1010.9//1100.9//1110.1測(cè)試樣本可以自己試試這些數(shù)據(jù)//00.10.9(期望:0.1)//0.90.90.1(期望0.9)-----------------------------------------分割線---------------
2、--------------------------#include"stdlib.h"#include"math.h"#include"conio.h"#include"stdio.h"#include"time.h"#defineN8/*學(xué)習(xí)樣本個(gè)數(shù)(測(cè)試樣本個(gè)數(shù))*/#defineIN3/*輸入層神經(jīng)元數(shù)目*/#defineHN2/*隱層神經(jīng)元數(shù)目*/#defineON1/*輸出層神經(jīng)元數(shù)目*/floatP[IN];/*單個(gè)樣本輸入數(shù)據(jù)*/floatT[ON];/*單個(gè)樣本教師數(shù)據(jù)*/floatW[HN][I
3、N];/*輸入層至隱層權(quán)值*/floatV[ON][HN];/*隱層至輸出層權(quán)值*/floatX[HN];/*隱層的輸入*/floatY[ON];/*輸出層的輸入*/floatH[HN];/*隱層的輸出*/floatO[ON];/*輸出層的輸出*/floatYU_HN[HN];/*隱層的閾值*/floatYU_ON[ON];/*輸出層的閾值*/floaterr_m[N];/*第m個(gè)樣本的總誤差*/floata;/*輸出層至隱層學(xué)習(xí)效率*/floatb;/*隱層至輸入層學(xué)習(xí)效率*/floatalpha;??/*/動(dòng)量
4、因子,改進(jìn)型bp算法使用*/floatd_err[ON];/*δk*/floate_err[HN];/*δj*/FILE*fp;/*定義一個(gè)放學(xué)習(xí)樣本的結(jié)構(gòu)*/struct{floatinput[IN];floatteach[ON];???????}Study_Data[N];/*定義一個(gè)放測(cè)試樣本的結(jié)構(gòu)*/struct{floatinput[IN];floatexpect[ON];???????}Test_Data[N];/*改進(jìn)型bp算法用來保存每次計(jì)算的權(quán)值*/floatold_W[HN][IN];float
5、old_V[ON][HN];intStart_Show(){clrscr();printf("???????????????????????***********************");printf("???????????????????????*????Welcometouse???*");printf("???????????????????????*??thisprogramof????*");printf("???????????????????????*??calculatingt
6、heBP*");printf("???????????????????????*??????model!?????????*");printf("???????????????????????*???Happyeveryday!??*");printf("???????????????????????***********************");printf("Beforestarting,pleasereadthefollowscarefully:");printf("???
7、?TheprogramofBPcanstudyitselffornomorethan200000times.Andsurpassingthenumber,theprogramwillbeendedbyitselfinpreventingrunninginfinitelybecauseoferror!");printf("");printf("Nowpressanykeytostart...");getch();clrscr();}intEnd_Show(){printf("---
8、------------------------------------------------");printf("Theprogramhasreachedtheendsuccessfully!Pressanykeytoexit!");printf("???????????????????????******************