程序255 发表于 2007-5-7 18:44

神经网络分类器的问题

怎么 老是说不完整啊


s=3;
q=8;
p=3;
r=3;
E=0;
m=24;
O=zeros(1,r);
X=zeros(1,s);
Y=zeros(1,q);
Z=zeros(1,p);
W1=[-0.25,0.35,0.24];
W2=[-0.25,0.35,0.24];
W3=[-0.25,0.35,0.24];
W4=[-0.25,0.35,0.24];
W5=[-0.25,0.35,0.24];
W6=[-0.25,0.35,0.24];
W7=[-0.25,0.35,0.24];
W8=[-0.25,0.35,0.24];
N1=[-0.25,0.35,0.24,-0.13,-0.25,0.35,0.24,-0.13];
N2=[-0.25,0.35,0.24,-0.13,-0.25,0.35,0.24,-0.13];
N3=[-0.25,0.35,0.24,-0.13,-0.25,0.35,0.24,-0.13];
B=[0.8645,2.3053,0.9288;
      0.1473,0.4372,0.3926;
      0.3962,0.7500,1.5238;
      0.8329,1.9963,0.9625;
      0.1526,0.4592,0.4588;
      0.3687,0.8138,2.8823;
      0.9498,2.4015,0.9466;
      0.3421,1.0006,0.5166;
      0.4444,1.0012,2.1818;
      0.8735,2.4342,0.8956;
      0.3164,0.9250,0.1875;
      0.2921,0.9845,2.3000;
      0.7797,1.5103,0.9315;
      0.2311,0.9459,0.1306;
      0.3319,1.0754,1.4878;
      0.8805,1.5903,0.9466;
      0.1534,0.5280,0.5172;
      0.3745,1.3827,1.3600;
      0.7453,1.3771,0.9543;
      0.3005,0.8375,0.1874;
      0.2747,0.9566,1.4878;
      0.8456,1.7366,0.9721;
      0.3926,1.0277,0.1875;
      0.3331,1.1811,1.5531];
    P=[1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1];
for i=1:m
    X=B(i,:);O=P(i,:);
   
for j=1:q
    TT=0;
    for i=1:s
      TT=TT+X(1,i)*Wj(i);
    end;
   Y(j)=1/(1+e^(-TT));
end;
for j=1:p
    PP=0;
    for i=1:q
      PP=PP+Y(1,i)*Nj(i);
    end;
    Z(j)=1/(1+e^(-PP));
end;
for i=1:p
    E=E+{O(i)-Z(i)}^2;
end;
   

   
   while sqrt(E/(m*p))> 0.5
for i=1:p
    for j=1:q
Ni(j)=Ni(j)+a*(Oi-Zi)*(e^(-PP)/(1+e^(-2*PP)+2*(e^(-PP))))*Y(j);
    end;
end;
for i=1:q
    for j=1:s
      u=0;
      for k=1:p
      u=Nk(i)*{O(k)-Z(k)}+u;
      Wi(j)=Wi(j)+a*(u)*(e^(-TT)/(1+e^(-2*TT)+2*(e^(-TT))))*X(j);
    end;
end;
E=0;
for i=1:m
    X=B(i,:);O=P(i,:);
   
for j=1:q
    TT=0;
    for i=1:s
      TT=TT+X(1,i)*Wj(i);
    end;
   Y(j)=1/(1+e^(-TT));
end;
for j=1:p
   PP=0;
    for i=1:q
      PP=PP+Y(1,i)*Nj(i);
    end;
    Z(j)=1/(1+e^(-PP));
end;
for i=1:p
    E=E+{O(i)-Z(i)}^2;
end;
end;
end;

eight 发表于 2007-5-7 23:42

原帖由 程序255 于 2007-5-7 18:44 发表 http://forum.vibunion.com/forum/images/common/back.gif
怎么 老是说不完整啊


s=3;
q=8;
p=3;
r=3;
E=0;
m=24;
O=zeros(1,r);
X=zeros(1,s);
Y=zeros(1,q);
Z=zeros(1,p);
W1=[-0.25,0.35,0.24];
W2=[-0.25,0.35,0.24];
W3=[-0.25,0.35,0.24];
W4= ...

你这样提问题估计无人帮到你,已经不是第一次了,建议先好好阅读置顶贴

xjzuo 发表于 2007-5-7 23:53

eight 说得对,希望下次将问题说清楚些.
提示: 可能少了end.
      另外,Wj的定义有问题.

程序255 发表于 2007-5-8 00:54

最后一个问题

s=3;
q=8;
p=3;
r=3;
E=0;
m=24;
a=0.3;
e=2.7183;
O=zeros(1,r);
X=zeros(1,s);
Y=zeros(1,q);
Z=zeros(1,p);
W=[-0.25,0.35,0.24;
-0.25,0.35,0.24;
-0.25,0.35,0.24;
-0.25,0.35,0.24;
-0.25,0.35,0.24;
-0.25,0.35,0.24;
-0.25,0.35,0.24;
-0.25,0.35,0.24]
N=[-0.25,0.35,0.24,-0.13,-0.25,0.35,0.24,-0.13;
-0.25,0.35,0.24,-0.13,-0.25,0.35,0.24,-0.13;
-0.25,0.35,0.24,-0.13,-0.25,0.35,0.24,-0.13];
B=[0.8645,2.3053,0.9288;
      0.1473,0.4372,0.3926;
      0.3962,0.7500,1.5238;
      0.8329,1.9963,0.9625;
      0.1526,0.4592,0.4588;
      0.3687,0.8138,2.8823;
      0.9498,2.4015,0.9466;
      0.3421,1.0006,0.5166;
      0.4444,1.0012,2.1818;
      0.8735,2.4342,0.8956;
      0.3164,0.9250,0.1875;
      0.2921,0.9845,2.3000;
      0.7797,1.5103,0.9315;
      0.2311,0.9459,0.1306;
      0.3319,1.0754,1.4878;
      0.8805,1.5903,0.9466;
      0.1534,0.5280,0.5172;
      0.3745,1.3827,1.3600;
      0.7453,1.3771,0.9543;
      0.3005,0.8375,0.1874;
      0.2747,0.9566,1.4878;
      0.8456,1.7366,0.9721;
      0.3926,1.0277,0.1875;
      0.3331,1.1811,1.5531];
    P=[1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1;
            1,0,0;
            0,1,0;
            0,0,1];
for i=1:m
    X=B(i,:);O=P(i,:);
   
for j=1:q
    TT=0;
    for i=1:s
      TT=TT+X(1,i)*W(j,i);
    end;
   Y(j)=1/(1+e^(-TT));
end;
for j=1:p
    PP=0;
    for i=1:q
      PP=PP+Y(1,i)*N(j,i);
    end;
    Z(j)=1/(1+e^(-PP));
end;
for i=1:p
    E=E+(O(i)-Z(i))^2;
end;
   

   
   while sqrt(E/(m*p))> 0.5
for i=1:p
    for j=1:q
N(i,j)=N(i,j)+a*(O(i)-Z(i))*(e^(-PP)/(1+e^(-2*PP)+2*(e^(-PP))))*Y(j);
    end;
end;
for i=1:q
    for j=1:s
      u=0;
      for k=1:p
      u=N(k,i)*(O(k)-Z(k))+u;
      W(i,j)= W(i,j)+a*(u)*(e^(-TT)/(1+e^(-2*TT)+2*(e^(-TT))))*X(j);
    end;
end;
E=0;
for i=1:m
    X=B(i,:);O=P(i,:);
   
for j=1:q
    TT=0;
    for i=1:s
      TT=TT+X(1,i)*W(j,i);
    end;
   Y(j)=1/(1+e^(-TT));
end;
for j=1:p
   PP=0;
    for i=1:q
      PP=PP+Y(1,i)*N(j,i);
    end;
    Z(j)=1/(1+e^(-PP));
end;
for i=1:p
    E=E+(O(i)-Z(i))^2;
end;
end;
end;
   end;
end;


程序是一个简单的神经网络分类器,有一个输入层(3个结点) ,一个隐含层(8个),一个输出曾(3个),B,P是样本向量组一行一个,P是B每一行对应的目标向量,下面是训练权值系数,当误差大于0.5时,就继续调节,可把0.5改成0.4或者更小就一直busy了 不知道是哪出了一 问题,是不是出现了振荡
页: [1]
查看完整版本: 神经网络分类器的问题