欢迎来到天天文库
浏览记录
ID:51910059
大小:39.50 KB
页数:5页
时间:2020-03-18
《模式识别_神经网络识别MATLAB实现.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、模糊神经网络模式识别functionretstr=FnnTrain(dt,ld,tt,sp)retstr=-1;%%%%输入参数赋值开始%%%%%%%%%%%%%%%%%%%%%%%%方便调试程序用,程序调试时去掉这部分的注释%dt=4; %学习阈值%ld=0.05; %学习进度%tt=10; %训练次数%sp='datasample.txt'; %一个点的监测数据%%%%输入参数赋值结束%%%%%%%%%%%%%%%%%%%%%%%%globalrecordDimention;globa
2、lsampleNumber;globalweightNumber;globaldistanceThread;globalWW;globallearningDegree;globalepochsNumber;distanceThread=dt;learningDegree=ld;traintimes=tt;A=load(sp); [ArowAcol]=size(A);%样本个数sampleNumber=Arow;recordDimention=Acol;disp(sampleNumber);WW=A(1,:);WW
3、=[WW[1]];weightNumber=1;epochsNumber=1; forjj=2:1:sampleNumber TrainNN2(A(jj,:));endforjt=1:traintimes-1 forjt2=1:sampleNumber TrainNN2(A(jj,:)); endend%将训练结果写入权值文件dlmwrite('dataw.dat',WW,'t');%%训练子函数%functionTrainNN2(a)globalrecordDimen
4、tion;globalsampleNumber;globalweightNumber;globaldistanceThread;globalWW;globallearningDegree;globalepochsNumber;Ldistance=zeros(2,weightNumber);forj1=1:weightNumber Ldistance(2,j1)=j1;end%%%%%%输入输出空间的模糊分割forj2=1:weightNumber Lx=0; forj3=1:recordDi
5、mention Lx=Lx+(a(j3)-WW(j2,j3)).*(a(j3)-WW(j2,j3)); end Ldistance(1,j2)=sqrt(Lx);end%%%%%%计算模糊空间的距离 Lx1=Ldistance(1,1);Lx2=Ldistance(2,1);forj4=2:weightNumber if(Ldistance(1,j4)6、; endend%%%%%%修正模糊规则updateW=0;nowWeight=Lx2;if(Lx1<=distanceThread) forj6=1:recordDimention WW(nowWeight,j6)=WW(nowWeight,j6)+learningDegree.*(a(j6)-WW(nowWeight,j6)); end WW(nowWeight,recordDimention+1)=WW(nowWeight,recordDimention+1)+7、1; updateW=1;end if(updateW==0) weightNumber=weightNumber+1; a=[a[1]]; WW=[WW;a];endL-M神经网络算法之MATLAB实现1%此为BP网络训练程序~k>8、H]x functionretstr=LmTrain(ModelNo,NetPara,TrainPara,InputFun,OutputFun,DataDir)$NiFfBf NNTWARNOFF~TVc'o> retstr=-19、;(`l/A+D] %%%%输入参数赋值开始%%%%%%%%%%%%%%%%%%%%%%%DH#D,zNI0 %方便调试程序用,程序调试时去掉这部分的注释T?u:'7n~W# ModelNo='1';;w.9{* NetPara(1)=7;eF*g}`Yib NetPara(2)=1;RVgB.dFf NetPara(3)=6;*dl10、ep
6、; endend%%%%%%修正模糊规则updateW=0;nowWeight=Lx2;if(Lx1<=distanceThread) forj6=1:recordDimention WW(nowWeight,j6)=WW(nowWeight,j6)+learningDegree.*(a(j6)-WW(nowWeight,j6)); end WW(nowWeight,recordDimention+1)=WW(nowWeight,recordDimention+1)+
7、1; updateW=1;end if(updateW==0) weightNumber=weightNumber+1; a=[a[1]]; WW=[WW;a];endL-M神经网络算法之MATLAB实现1%此为BP网络训练程序~k>
8、H]x functionretstr=LmTrain(ModelNo,NetPara,TrainPara,InputFun,OutputFun,DataDir)$NiFfBf NNTWARNOFF~TVc'o> retstr=-1
9、;(`l/A+D] %%%%输入参数赋值开始%%%%%%%%%%%%%%%%%%%%%%%DH#D,zNI0 %方便调试程序用,程序调试时去掉这部分的注释T?u:'7n~W# ModelNo='1';;w.9{* NetPara(1)=7;eF*g}`Yib NetPara(2)=1;RVgB.dFf NetPara(3)=6;*dl
10、ep
此文档下载收益归作者所有