|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
c=load('d:\c2.txt');
a=load('d:\a2.txt');
c=c';
a=a';
n=0;
dsum=1;
v=abs(randn(3,6)); %输入层至隐含层连接权
z1=randn(3,1);%输入层阈值
z=zeros(3,5);
z(:,1)=z1;
z(:,2)=z1;
z(:,3)=z1;
z(:,4)=z1;
z(:,5)=z1;
s=zeros(3,5);
b=zeros(3,5);
%隐含层至输出层
w=abs(randn(2,3)); %隐含层至输出层连接权
zy1=randn(2,1);%隐含层阈值
zy(:,1)=zy1;
zy(:,2)=zy1;
zy(:,3)=zy1;
zy(:,4)=zy1;
zy(:,5)=zy1;
l=zeros(2,5);
cc=zeros(2,5);
con=[1 1 1 1 1; 1 1 1 1 1];
d=zeros(2,5);
con2=[1 1 1 1 1;1 1 1 1 1;1 1 1 1 1];
SL1=randn(1,1);
SL2=randn(1,1);
while dsum>0.00001
s=v*a+z;
b=1./(1+exp(-s) );
%隐含层至输出层
l=w*b+zy;
cc=1./(1+exp(-l));
%计算误差
j=c-cc;
d=j.*c.*(con-c);
e=w'*d.*b.*(con2-b);
SL1=abs(randn(1,1));
SL2=abs(randn(1,1));
w=w+SL1*d*b';
zy=zy+SL1*d;
v=v+SL2*e*a';
z=z+SL2*e;
dsum=0;
for i=1:2
for j=1:5
dsum=dsum+abs(d(i,j));
end
end
n=n+1;
error(n)=dsum;
end
n1=1:n;
plot(n1,error)
错误信息:??? Error using ==> mtimes
Inner matrix dimensions must agree.
a2文件:
31
88
5
14
18
50
44
66
74
25
30
42
0
21
9
14
0
45
9
8
31
10
14
8
21
29
42
28
15
38
64
31
2
32
46
113
23
36
34
43
27
42
152
76
0
95
62
16
36
49
100
53
37
52
156 |
|