?? waveletnetwork.m
字號:
0.3811 0.2566 0.2041 0.1316 0.05012 0.1136 0.09829 0.06986 0.05041 0.02355
0.4076 0.2085 0.1105 0.05602 0.02857 0.1127 0.0818 0.06392 0.04779 0.03574
0.386 0.2868 0.2085 0.1128 0.1093 0.1142 0.08363 0.07118 0.03671 0.02668
0.3829 0.2309 0.1948 0.09944 0.07762 0.089 0.05745 0.03534 0.02746 0.02288
0.3872 0.2186 0.1502 0.1051 0.07756 0.1122 0.1002 0.0697 0.04102 0.03698
0.1944 0.1344 0.08911 0.07077 0.06299 0.3245 0.2426 0.1587 0.04624 0.04066
0.1752 0.151 0.11 0.1003 0.06794 0.3952 0.3333 0.1657 0.1466 0.141
0.2609 0.1828 0.1228 0.1131 0.07349 0.5937 0.4321 2794 0.2287 0.1079
0.1894 0.1275 0.1089 0.05754 0.04377 0.4197 0.2643 0.1836 0.1696 0.1232
0.2528 0.1769 0.1599 0.1149 0.07392 0.528 0.3445 0.2605 0.1817 0.08807
0.1684 0.09823 0.07031 0.05865 0.04059 0.4064 0.3307 0.2325 0.1746 0.1566
0.1815 0.1386 0.09682 0.06708 0.04781 0.4468 0.3768 0.3153 0.268 0.1181
0.1459 0.1012 0.07736 0.04293 0.0314 0.3186 0.2577 0.1687 0.1149 0.09182
0.1921 0.1613 0.143 0.1049 0.05965 0.3744 0.2644 0.2248 0.1894 0.1206
0.1854 0.1411 0.0812 0.0424 0.03398 0.3788 0.2299 0.101 0.06233 0.03213
0.1771 0.1043 0.08031 0.04995 0.03449 0.3815 0.273 0.2306 0.1422 0.105
0.1773 0.1104 0.08155 0.04932 0.02451 0.3471 0.2195 0.1719 0.1178 0.1093
0.1706 0.1017 0.06015 0.04211 0.03462 0.3396 0.1984 0.1045 0.05272 0.04299
0.1506 0.08778 0.06083 0.03166 0.02753 0.4079 0.2866 0.126 0.1169 0.08921
0.1555 0.1235 0.08281 0.06462 0.0567 0.4068 0.2549 0.1723 0.1192 0.09939
0.1805 0.1179 0.07706 0.04081 0.03552 0.3905 0.321 0.1304 0.06539 0.05561
0.1404 0.09726 0.06411 0.04189 0.02155 0.4406 0.2687 0.193 0.09314 0.06491
0.1737 0.1058 0.08523 0.04828 0.02924 0.456 0.262 0.2287 0.1996 0.1201
0.1574 0.09068 0.07044 0.0549 0.0411 0.3696 0.2813 0.1621 0.1375 0.119
0.1599 0.09374 0.07137 0.04796 0.04027 0.3905 0.1833 0.1127 0.06366 0.0535
0.3396 0.2285 0.1647 0.1471 0.0784 0.1555 0.1212 0.1018 0.09709 0.06911
0.4138 0.2889 0.1357 0.06496 0.0441 0.2484 0.1683 0.1413 0.1157 0.01681
0.2543 0.1801 0.1131 0.08648 0.06785 0.1846 0.1497 0.1218 0.06232 0.04515
0.2948 0.1993 0.1141 0.09066 0.05919 0.1949 0.1671 0.1357 0.06733 0.0592
0.2187 0.1466 0.1062 0.09575 0.08838 0.1386 0.1037 0.05508 0.0301 0.0286
0.2602 0.1936 0.1511 0.1303 0.112 0.1294 0.06769 0.0453 0.02471 0.01854
0.3311 0.2483 0.2352 0.14 0.08499 0.1757 0.1435 0.1112 0.02748 0.01671
0.29 0.1563 0.1436 0.1081 0.0873 0.1798 0.1284 0.1109 0.1017 0.07002
0.2557 0.1665 0.1549 0.04602 0.03449 0.2276 0.09191 0.0694 0.03844 0.01514
0.2579 0.2229 0.1629 0.07591 0.05771 0.1705 0.09039 0.07068 0.0742 0.01831
0.3457 0.1858 0.1482 0.09657 0.03509 0.226 0.1376 0.1171 0.05694 0.04225
0.3523 0.2043 0.1349 0.09242 0.04402 0.1925 0.1454 0.1111 0.085 0.06024
0.4625 0.3877 0.1973 0.136 0.1217 0.1579 0.1117 0.0924 0.03456 0.02188
0.5091 0.4448 0.2847 0.2736 0.08984 0.2054 0.162 0.1104 0.04705 0.0364
0.3061 0.1501 0.07541 0.05767 0.03728 0.2238 0.2047 0.1657 0.1077 0.09818
0.2928 0.2269 0.1473 0.1009 0.06514 0.1388 0.06188 0.04765 0.02406 0.01718
0.3784 0.2786 0.1299 0.1038 0.06199 0.1804 0.132 0.09684 0.05619 0.04992
0.3261 0.2694 0.1735 0.1327 0.1201 0.2219 0.1255 0.1 0.08241 0.02495
0.2811 0.2203 0.1817 0.0828 0.03257 0.2063 0.1125 0.09054 0.07212 0.03864
0.3119 0.2408 0.2094 0.1287 0.04976 0.1856 0.1368 0.08419 0.06293 0.02899]'
x2=[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
P=3 %numberof sample
m=1%number of input node
n=10%number of hidden node
N=1%number of ouptut node
%
%a(n) b(n) scale and shifting parameter matrix
%x(P,m) input matrix of P sample
%net(P,n) ouput of hidden node
%y(P,N) output of network
%d(P,N) ideal output of network
% phi(P,n) ouput of hidden node wavelet funciton
%W(N,n)weight value between ouput and hidden
%WW(n,m) weight value between hidden and input node
x=[4;5;6]
d=[1.3;3.6;6.7]
W=rand(N,n)
WW=rand(n,m)
a=ones(1,n)
for j=1:n
b(j)=j*P/n;
end
%%%%%%%%%%%%%%%%%%
%EW(N,n) gradient of W
%EWW(n,m) gradient of WW
%Ea(n) gradient of a
%Eb(n) gradient of b
%%%%%%%%%%%%%%]
epoch=1;
epo=100;
error=0.05;
err=0.01;
delta =1;
lin=0.5;
while (error>=err & epoch<=epo)
u=0;%u is the middle variant
%caculation of net input
for p=1:P
for j=1:n
u=0;
for k=1:m
u=u+WW(j,k)*x(p,k);
end
net(p,j)=u;
end
end
%calculation of morlet 0r mexican wavelet output
for p=1:P
for j=1:n
u=net(p,j);
u=(u-b(j))/a(j);
phi(p,j)=cos(1.75*u)*exp(-u*u/2); %morlet wavelet
%phi(p,j)=(1-u^2)*exp(-u*u/2); %mexican hat wavelet
end
end
%calculation of output of network
for p=1:P
for i=1:N
u=0;
for j=1:n
u=u+W(i,j)*phi(p,j);
end
y(p,i)=delta*abs(u);
end
end
%calculation of error of output
u=0;
for p=1:P
for i=1:N
u=u+abs(d(p,i)*log(y(p,i))+(1-d(p,i)*log(1-y(p,i))));
%u=u+(d(p,i)-y(p,i))^2;
end
end
%u=u/2
error=u;
%calculate of gradient of network
for i=1:N
for j=1:n
u=0;
for p=1:P
u=u+(d(p,i)-y(p,i))*phi(p,j);
end
EW(i,j)=u;
%EW(i,j)=-u;%the resule would be wrong
end
end
for j=1:n
for k=1:m
u=0
for p=1:P
for i=1:N
u=u+(d(p,i)-y(p,i))*W(i,j)*phi(p,j)*x(p,k)/a(j) ;
end
end
EWW(j,k)=u;
%EWW(j,k)=u the result would be wrong
end
end
for j=1:n
u=0
for p=1:P
for i=1:N
u=u+(d(p,i)-y(p,i))*W(i,j)*phi(p,j)/a(j) ;
end
end
Eb(j)=u;
end
for j=1:n
u=0
for p=1:P
for i=1:N
u=u+(d(p,i)-y(p,i))*W(i,j)*phi(p,j)*((net(p,j)-b(j))/b(j))/a(j) ;
end
end
Ea(j)=u;
end
%adjust of weight value
WW=WW-lin*EWW;
W=W-lin*EW;
a=a-lin*Ea;
b=b-lin*Eb;
%number of epoch increase by 1
epoch=epoch+1;
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -