資源描述:
《神經(jīng)網(wǎng)絡(luò)BP算法程序C語(yǔ)言.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、神經(jīng)網(wǎng)絡(luò)BP算法(C程序)文件輸入輸出目錄為:F:BP訓(xùn)練樣本文件名:訓(xùn)練樣本.txt值為:11-11-110101輸出文件名為:閾值.txt???權(quán)值.txt=========================#include"stdlib.h"#include"math.h"#include"conio.h"#include"stdio.h"#defineN2/*/學(xué)習(xí)樣本個(gè)數(shù)*/#defineIN3/*/輸入層神經(jīng)元數(shù)目*/#defineHN3/*/隱層神經(jīng)元數(shù)目*/#defineON2/*/輸出層神經(jīng)元數(shù)目*/#defineZ20/*舊權(quán)值
2、保存,每次study的權(quán)值都保存下來(lái)*/doubleP[IN];/*單個(gè)樣本輸入數(shù)據(jù)*/doubleT[ON];/*單個(gè)樣本輸出數(shù)據(jù)*/doubleW[HN][IN];/*/輸入層至隱層權(quán)值*/doubleV[ON][HN];/*/隱層至輸出層權(quán)值*/doubleX[HN];/*/隱層的輸入*/doubleY[ON];/*/輸出層的輸入*/doubleH[HN];/*/隱層的輸出*/doubleO[ON];/*/輸出層的輸出*/doubleYU_HN[HN];/*/隱層的閾值*/doubleYU_ON[ON];/*/輸出層的閾值*/doubleerr
3、m[N];/*/第m個(gè)樣本的總誤差*/doublea;/*/輸出層至隱層的學(xué)習(xí)效率*/doubleb;/*/隱層至輸入層學(xué)習(xí)效率*/doublealpha;?/*/動(dòng)量因子,改進(jìn)型bp算法使用*/doublederr[ON];FILE*fp;/*定義一個(gè)放學(xué)習(xí)樣本的結(jié)構(gòu)*/struct{doubleinput[IN];doubleteach[ON];}Study_Data[N];/*改進(jìn)型bp算法用來(lái)保存每次計(jì)算的權(quán)值*/struct{doubleold_W[HN][IN];doubleold_V[ON][HN];}Old_WV[Z];顯示開始界面i
4、ntStart_Show(){clrscr();printf("??????????????????????***********************");printf("??????????????????????*???Welcometouse??*");printf("??????????????????????*?thisprogramof???*");printf("??????????????????????*?calculatingtheBP*");printf("??????????????????????*?
5、????model!????????*");printf("??????????????????????*??Happyeveryday!?*");printf("??????????????????????***********************");printf("Beforestarting,pleasereadthefollowscarefully:");printf("???1.PleaseensurethePathofthe'訓(xùn)練樣本.txt'(xunlianyangben.txt)iscorrect
6、,like'F:BP訓(xùn)練樣本.txt'!");printf("???2.ThecalculatingresultswillbesavedinthePathof'F:\BP\'!");printf("???3.Theprogramwillload10dataswhenrunningfrom'F:\BP\訓(xùn)練樣本.txt'!");printf("???4.TheprogramofBPcanstudyitselffornomorethan30000times.Andsurpassingthenumber,theprogramwi
7、llbeendedbyitselfinpreventingrunninginfinitelybecauseoferror!");printf("");printf("Nowpressanykeytostart...");getch();getch();clrscr();}顯示結(jié)束界面intEnd_Show(){printf("---------------------------------------------------");printf("Theprogramhasreachedtheendsuccessf
8、ully!Pressanykeytoexit!");printf("??????????