声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1124|回复: 3

[编程技巧] 神经网络分类器的问题

[复制链接]
发表于 2007-5-7 18:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
怎么 老是说不完整啊


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;
回复
分享到:

使用道具 举报

发表于 2007-5-7 23:42 | 显示全部楼层
原帖由 程序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= ...


你这样提问题估计无人帮到你,已经不是第一次了,建议先好好阅读置顶贴
发表于 2007-5-7 23:53 | 显示全部楼层
eight 说得对,希望下次将问题说清楚些.
提示: 可能少了end.
        另外,Wj的定义有问题.
 楼主| 发表于 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了 不知道是哪出了一 问题,是不是出现了振荡
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-14 05:34 , Processed in 0.066705 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表