径向基神经网络(实例故障分类)
生活随笔
收集整理的這篇文章主要介紹了
径向基神经网络(实例故障分类)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
徑向神經網絡的創建:
調用格式:
net=newrbe(p,t,spread) -------------------p ?t分別為輸入和輸出樣本,spread ?為徑向神經網絡的散布常數
或者更高效的神經網絡
net=newrb(p,t,goal,spread);
概率神經網絡的創建:
<span style="font-size:18px;"><span style="font-size:18px;"><strong>P = [0 0;1 1;0 3;1 4;3 1;4 1;4 3]', Tc = [1 1 2 2 3 3 3],T = ind2vec(Tc); %吧分類標簽轉換成向量的形式net = newpnn(P,T); %創建概率神經網絡 Y = sim(net,P); %生成概率神經網絡計算的值 Yc = vec2ind(Y) %將向量標簽改換成位置標簽P2 = [1 4;0 1;5 2]', Y = sim(net,P2); Yc = vec2ind(Y)</strong></span></span> ?廣義回歸神經網絡的創建:newgrnn(p,t)
徑向神經網絡的設計實例:
徑向基網絡函數的逼近:
<span style="font-size:18px;"><span style="font-size:18px;"><strong>P = -1:.1:1; T = [-.9602 -.5770 -.0729 .3771 .6405 .6600 .4609 ....1336 -.2013 -.4344 -.5000 -.3930 -.1647 .0988 ....3072 .3960 .3449 .1816 -.0312 -.2189 -.3201]; plot(P,T,'+'); title('訓練樣本(Training Vectors)'); xlabel('輸入樣本向量(Input Vector P)'); ylabel('目標向量(Target Vector T)');p = -3:.1:3; a = radbas(p); %隱含層和輸出層之間的徑向傳遞函數 plot(p,a) title('徑向基傳遞函數'); xlabel('輸入 p'); ylabel('輸出 a');a2 = radbas(p-1.5); a3 = radbas(p+2); a4 = a + a2*1 + a3*0.5; plot(p,a,'b-',p,a2,'b-',p,a3,'b-',p,a4,'m--') title('徑向基傳遞函數加權和'); xlabel('輸入 p'); ylabel('輸出 a');eg = 0.02; % 期望均方誤差 sc = 1; % 雜散常數 net = newrb(P,T,eg,sc); %生成徑向基神經網絡,并且進行訓練plot(P,T,'+'); xlabel('Input'); X = -1:.01:1; Y = sim(net,X); %生成預測的值 hold on; plot(X,Y); hold off; legend({'目標向量','網絡輸出'}) </strong></span></span>
下面是散布常數選擇不當時的場景。
<span style="font-size:18px;"><span style="font-size:18px;"><strong>P = -1:.1:1; T = [-.9602 -.5770 -.0729 .3771 .6405 .6600 .4609 ....1336 -.2013 -.4344 -.5000 -.3930 -.1647 .0988 ....3072 .3960 .3449 .1816 -.0312 -.2189 -.3201]; plot(P,T,'+'); title('訓練樣本(Training Vectors)'); xlabel('輸入樣本向量(Input Vector P)'); ylabel('目標向量(Target Vector T)');eg = 0.02; % 期望均方誤差 sc = .01; % 散布常數 net = newrb(P,T,eg,sc);X=-1:.01:1; Y=sim(net,X); hold on; plot(X,Y); hold off; </strong></span></span><span style="font-size:18px;"><span style="font-size:18px;"><strong>P = -1:.1:1; T = [-.9602 -.5770 -.0729 .3771 .6405 .6600 .4609 ....1336 -.2013 -.4344 -.5000 -.3930 -.1647 .0988 ....3072 .3960 .3449 .1816 -.0312 -.2189 -.3201]; plot(P,T,'+'); title('訓練樣本(Training Vectors)'); xlabel('輸入樣本向量(Input Vector P)'); ylabel('目標向量(Target Vector T)');eg = 0.02; % 期望均方誤差 sc =100; % 散布常數 net = newrb(P,T,eg,sc);X=-1:.01:1; Y=sim(net,X); hold on; plot(X,Y); hold off; </strong></span></span>
概率神經網絡的分類問題:
<span style="font-size:18px;"><span style="font-size:18px;"><strong>P = [1 2; 2 2; 1 1]'; Tc = [1 2 3]; plot(P(1,:),P(2,:),'.','markersize',30) for i=1:3, text(P(1,i)+0.1,P(2,i),sprintf('class %g',Tc(i))), end axis([0 3 0 3]) title('3個樣本向量') xlabel('P(1,:)') ylabel('P(2,:)')%% T = ind2vec(Tc); spread = 1; net = newpnn(P,T,spread);A = sim(net,P); Ac = vec2ind(A); plot(P(1,:),P(2,:),'o','markersize',10) axis([0 3 0 3]) for i=1:3,text(P(1,i)+0.1,P(2,i),sprintf('class %g',Ac(i))),end title('網絡仿真測試結果') xlabel('P(1,:)') ylabel('P(2,:)') %% p = [2; 1.5]; a = sim(net,p); ac = vec2ind(a); hold on plot(p(1),p(2),'.','markersize',30,'color',[1 0 0]) text(p(1)+0.1,p(2),sprintf('class %g',ac)) hold off title('新輸入樣本的分類仿真結果') xlabel('P(1,:) and p(1)') ylabel('P(2,:) and p(2)') %% p1 = 0:.05:3; p2 = p1; [P1,P2] = meshgrid(p1,p2); pp = [P1(:) P2(:)]'; aa = sim(net,pp); aa = full(aa); m = mesh(P1,P2,reshape(aa(1,:),length(p1),length(p2))); %% set(m,'facecolor',[0 0.5 1],'linestyle','none'); hold on m = mesh(P1,P2,reshape(aa(2,:),length(p1),length(p2))); set(m,'facecolor',[0 1.0 0.5],'linestyle','none'); m = mesh(P1,P2,reshape(aa(3,:),length(p1),length(p2))); set(m,'facecolor',[0.5 0 1],'linestyle','none'); plot3(P(1,:),P(2,:),[1 1 1]+0.1,'.','markersize',30) %% plot3(p(1),p(2),1.1,'.','markersize',30,'color',[1 0 0]) hold off view(2) title('3類劃分區域') xlabel('P(1,:) and p(1)') ylabel('P(2,:) and p(2)') </strong></span></span>[filename, pathname] = uigetfile('16_5_P.xls'); file=[pathname filename]; x=xlsread(file); p=x; p=p'; t1=[0.9 0.1 0.1]' t2=[0.1 0.9 0.1]' t3=[0.1 0.1 0.9]' t = [t1 t1 t1 t1 t1 t2 t2 t2 t2 t2 t3 t3 t3 t3 t3];spread = 0.6; net = newrbe(p,t,spread);[filename, pathname] = uigetfile('16_5_Ptest.xls'); file=[pathname filename]; xtest=xlsread(file); ptest=xtest; ptest=ptest'; ans = sim(net, ptest),
總結
以上是生活随笔為你收集整理的径向基神经网络(实例故障分类)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MATLAB中的ind2vec和vec2
- 下一篇: Matlab稀疏矩阵