马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
我现在写了一个关于通过比较训练后的自组织神经网络与数据的相似度来达到预测未来数据的趋势的方程。
但是我发现可能是学习方法不对。或者是邻域节点的公式不对。预测出来的数据很多都是一样的..谁知道这个问题应该怎么解决啊?
%% data pre-process
% Training 230 data.
x = [1.95950 1.9660 1.96760 1.96660 1.96660 1.96230 1.96430 1.97060 1.96620 1.95380 1.94980 1.94970 1.950 1.94640 1.95230 1.96030 1.95110 1.95020 1.95020 1.95130 1.95260 1.95410 1.95310 1.95890 1.96380 1.96390 1.96350 1.96420 1.96090 1.9620 1.95240 1.9440 1.94550 1.92830 1.92560 1.93070 1.93130 1.93090 1.93260 1.93290 1.93450 1.93140 1.92880 1.93560 1.94160 1.94310 1.9430 1.94320 1.95120 1.96140 1.96790 1.96420 1.9620 1.9620 1.96310 1.96720 1.96470 1.96350 1.96250 1.96850 1.96850 1.97280 1.97750 1.97470 1.97390 1.96930 1.96590 1.9660 1.96370 1.96910 1.97600 1.97670 1.98360 1.98680 1.98670 1.98940 1.99680 2.00770 2.0040 2.00350 2.00280 2.00280 2.00210 1.99970 2.00340 1.99870 1.99450 1.99830 1.99830 1.99610 2.00110 1.99410 1.99020 1.98890 1.99280 1.99280 1.99550 1.99290 1.99220 1.98920 1.98030 1.98190 1.9820 1.98210 1.98040 1.98340 1.97660 1.97420 1.97520 1.97520 1.97240 1.97270 1.97950 1.98630 1.98530 1.98420 1.98420 1.98390 1.98390 1.97830 1.97700 1.97980 1.9830 1.9830 1.98610 1.99290 1.99350 1.98810 1.97210 1.97050 1.97060 1.96790 1.97290 1.97260 1.97080 1.97190 1.97660 1.97670 1.98160 1.98570 1.99060 1.99220 1.99440 1.99980 1.99980 1.99910 1.99880 1.99720 2.00120 2.00390 2.00920 2.00920 2.01120 2.0170 2.01730 2.01530 2.01090 2.01140 2.01140 2.01340 2.01810 2.02960 2.03180 2.03140 2.03480 2.03480 2.03630 2.0410 2.05090 2.05110 2.05160 2.05670 2.05670 2.05770 2.06240 2.05620 2.05030 2.03850 2.02480 2.02470 2.02430 2.03120 2.0280 2.03180 2.03780 2.04130 2.04120 2.03720 2.02770 2.02750 2.03230 2.02130 2.02370 2.02360 2.01810 2.0060 1.99230 1.98420 1.98090 1.98160 1.98160 1.98360 1.98390 1.98570 1.99960 2.00620 2.01480 2.01480 2.01560 2.00830 2.00700 2.01390 2.01610 2.01750 2.01750 2.01770 2.01550 2.01410 2.02130 2.02350 2.02920 2.02920 2.02920 2.02890 2.03220 2.02830 2.0160 2.00780 2.00780 2.00210];
% Testing 136 data.
y = [1.99530 2.0070 2.00550 2.01390 2.02070 2.02070 2.02390 2.01580 2.01660 2.02070 2.03070 2.04770 2.04770 2.04470 2.04140 2.03950 2.0340 2.03890 2.04250 2.04250 2.03940 2.03330 2.0410 2.03820 2.03170 2.03670 2.03660 2.0380 2.03750 2.03410 2.04320 2.04690 2.05230 2.05240 2.04270 2.04060 2.04890 2.04930 2.05230 2.05270 2.05280 2.05760 2.06360 2.07190 2.08030 2.08230 2.08950 2.08940 2.08490 2.08450 2.09650 2.10390 2.1050 2.09080 2.09070 2.0760 2.06530 2.07160 2.05150 2.04480 2.05510 2.05530 2.05210 2.05690 2.0630 2.0640 2.06360 2.06320 2.06320 2.06610 2.07030 2.06720 2.07050 2.06280 2.05670 2.05680 2.06030 2.06260 2.04570 2.02740 2.02800 2.0310 2.03090 2.0380 2.0460 2.04130 2.04340 2.03360 2.01820 2.01820 2.01720 2.01820 2.0090 1.99210 1.98550 1.9840 1.98410 1.98140 1.97740 1.98090 1.98850 1.9960 1.99710 1.99730 1.9970 1.98560 1.98430 1.97860 1.97380 1.97440 1.97460 1.97180 1.97340 1.96710 1.95830 1.95870 1.95750 1.95760 1.960 1.96140 1.96160 1.96680 1.96460 1.95580 1.95590 1.95070 1.94780 1.95640 1.96010 1.97910 1.98360 1.98370 1.98190 1.98640 1.990 1.98830];
% Testing from 10th value of testing data
m = 10;
%% initialise model parameters
% 1x10 SOM
for i = 1
for j = 1:10
w(i,j,:) = rand(1,10);
end
end
% Training
for t = 1:5000
if rem(t,100) == 0
t
end
n = 10+floor(rand*220);
xx = [x(n) x(n-1) x(n-2) x(n-3) x(n-4) x(n-5) x(n-6) x(n-7) x(n-8) x(n-9)];
a = 0.5 * 100/(100+t); % learning rate
b = 0.9 + 7*100/(5000+t); % Gaussian distribution rate
for i = 1
for j = 1:10
ww = reshape(w(i,j,:),1,10);
d(i,j) = (xx-ww)*(xx-ww)';
end
end
vi = 1;
vj = 1;
for i = 1
for j = 1:10
if d(i,j)<d(vi,vj)
vj = j;
end
end
end
for i = 1
for j = 1:10
dd = (j-vj)^2;
yy = reshape(xx,1,1,10);
w(i,j,:) = w(i,j,:) + a*exp(-dd/(2*b*b))*(yy-w(i,j,:));
end
end
end
% Testing
while m < 137
zz = [y(m) y(m-1) y(m-2) y(m-3) y(m-4) y(m-5) y(m-6) y(m-7) y(m-8) y(m-9)];
for i = 1;
for j = 1:10;
ww1 = reshape(w(i,j,:),1,10);
xx1 = ww1(2:10);
zz1 = zz(2:10);
p(i,j) = (zz1-xx1)*(zz1-xx1)';
end
end
vx = 1;
vz = 1;
for i = 1;
for j = 1:10;
if p(i,j)<p(vx,vz);
vz = j;
end
end
end
pp(m) = w(vx,vz,1);
m = m+1;
end |