www.pudn.com > dbn.zip > bp.m, change:2012-05-21,size:935b


 
clear all; 
clc; 
close all; 
 
load traindata 
traindat=traindata(2:2:18000,:); 
trainlabel=label(2:2:18000,:); 
testdata=traindata(1:2:18000,:); 
testlabels=label(1:2:18000,:); 
      T = [0 1 2 3 4 3 2 1 2 3 4]; 
 
% A two-layer cascade-forward network is created with one hidden layer of five neurons. 
 
%     * 
 
      net = newcf(traindat',trainlabel',[30,30]); 
 
% The network is simulated and its output plotted against the targets. 
%  
%     * 
 
      Y = sim(net,testdata'); 
%       plot(P,T,P,Y,'o') 
 
% The network is trained for 50 epochs. Again the network's output is plotted. 
 
%     * 
      plot(Y,'*'); 
      hold on 
      plot(testlabels) 
      net.trainParam.epochs = 150; 
      net = train(net,traindat',trainlabel'); 
      Y1= sim(net,testdata'); 
      plot(Y1,'r-.') 
      Y2=Y1>1.5; 
      Y2=Y2+1; 
      zz=sum(testlabels'~=Y2); 
      zzz=zz/length(Y2); 
       
%       plot(P,T,P,Y,'o')