马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
<P>我在编程时在第41行出现一个错误,谁帮我看,错误提示是R,Q <br><FONT color=#f73809>Undefined function or variable "R".</FONT><br>%用基BP网络进行英文字符识别<br>close all<br>clear<br>echo on<br>clc<br>pause<br>clc</P>
<P><br>%载入训练样本<br>[alphabet,targets]=prprob;<br>[R1,Q1]=size(alphabet);<br>[R2,Q2]=size(targets);<br>pause<br>clc<br>S1=10;<br>S2=R2;<br>net=newff(minmax(alphabet),[S1 S2],{'logsig' 'logsig'},'traingdx');<br>net.LW{2,1}=net.LW{2,1}*0.01;<br>net.b{2}=net.b{2}*0.01;<br>pause<br>clc<br>%训练神经网络<br>P=alphabet;<br>T=targets;<br>net.performFcn='sse';<br>net.trainParam.goal=0.1;<br>net.trainParam.show=20;<br>net.trainParam.epochs=5000;<br>net.trainparam.mc=0.95;<br>[net,tr]=train(net,P,T);<br>pause<br>clc</P>
<P>%netn=net;<br>%netn.trainParam.goal=0.6;<br>%netn.trainParam.epochs=300;<br>T=[targets targets targets targets];<br>for pass=1:10<br> <STRONG><FONT color=#e66b1a>fprintf('Pass=%.0f\n',pass);<br> P =[alphabet,alphabet,... %这是第41行<br></FONT></STRONG> (alphabet+randn(R,Q)*0.1),...<br> (alphabet+randn(R,Q)*0.2)];<br> [netn,tr]=train(netn,P,T);<br> echo off<br>end<br>echo on<br>pause<br>clc</P>
<P>netn.trainParam.goal=0.1;<br>netn.trainParam.epochs=500;<br>netn.trainParam.show=5;<br>P=alphabet;<br>T=targets;<br>[netn,tr]=train(netn,P,T);<br>pause<br>clc</P>
<P>noise_range=0:.05:.5;<br>max_test=100;<br>network1=[];<br>network2=[];</P>
<P>for noiselevel=noise_range<br> fprintf('Testing networks with noise level of%.2f.\n',noiselevel);<br> errors1=0;<br> errors2=0;<br> for i=1:max_test<br> P=alphabet+rand(35,26)*noiselevel;<br> A=sim(net,P);<br> AA=compet(A);<br> errors1=errors1+sum(sum(abs(AA-T)))/2;<br> <br> An=sim(netn,P);<br> AAn=compet(An);<br> errors2=errors+sum(sum(abs(AAn-t)))/2;<br> echo off<br> end<br> network1=[network1 error1/26/100];<br> network2=[network2 error2/26/100];<br>end<br>echo on<br>pause<br>clc</P>
<P>plot(noise_range,network1*100,'--',noise_range,network2*100);<br>tille('Percentage of Recognition Errors(%)');<br>xlabel('Noise Level');<br>ylabel('Network 1-- Network 2--');<br>pause clc</P>
<P>noiseyB=alphabet(:,2)+randn(35,1)*0.2;</P>
<P>plotchar(noisyB);<br>pause<br>clc</P>
<P>A2=sim(net,noiseyB);<br>A2=compet(A2);<br>answer=find(compet(A2)==1);<br>plotchar(alphabet(:,answer));<br>pause<br>echo off<br>帮我改正,我感激不尽!!!</P>
[此贴子已经被作者于2006-6-3 17:14:04编辑过]
|