神经网络课程设计 神经网络用于机器手臂的控制
训练第四次
SSE =5.0070e-006
四次训练以后的权值分布
张建文 1030319100 张卜南1030319078
神经网络课程设计 神经网络用于机器手臂的控制
在机器人控制,使用了书上的学习步长为0.00001,但是在实际使用中,效果不是很好,收敛太慢,在实际学习中使用的学习步长是0.1,效果比较明显,然而当学习步长为0.5,1.0的时候算法变得不收敛,在本程序中可以在matlab的环境对这几种学习步长进行比较.可以具体运行程序观察。 6.不足
对学习步长得确定没有通过具体的分析,是通过猜测估计得到.而算法的实现很重要的一节是其鲁棒性的测试,但是由于时间问题没有对它的鲁棒性进行分析。这是很大的不足之处。 7.补充
在算法中求对物理地址的实际映射使用的算法有很多。本程序还使用了来自网络的算法。同样可以得到书上算法的效果,但在实验中没有具体分析各个算法不同之处。希望在将来里能更深入的研究。
附录
程序一
function cmac1d()
% A single input single output CMAC network help cmac1d clf reset
pausetime = 0.1; P = -1:0.1:1; P3 = -1:0.005:1; % INITIALIZE
iprange = 256;
disp(sprintf('iprange is %d',iprange)); width=1; c=10;
beta=0.5;
memreq = c*ceil(iprange/width);
s = sprintf('number of weights required is %d',memreq); disp(s); memsize=0;
% INITIALISE WEIGHTS % ==================
张建文 1030319100 张卜南1030319078
神经网络课程设计 神经网络用于机器手臂的控制
if memsize == 0
wts = zeros(memreq,1); else
wts = zeros(memsize,1); end
% PLOT CMAC OUTPUT
[wts,netout] = modcmac(wts,[(2.0)*64],1,1.0,1.0,iprange,c,width,memsize);
for k=1:401
[wts,op(k)] = opcmac(wts,[(P3(k)+2.0)*64],1,iprange,c,width,memsize); end;
plot(P3,op,'r');
axis([-1.0,1.0,-2.0,2.0]);
title('CMAC output after one training example'); xlabel('Input Vector P'); ylabel('Network Output');
disp('any key to continue');
pause
Tfine the associated twenty-one 1-element targets.
z = menu('select target function', ... 'damped sinusoid', ... 'step', ... 'impulse'); disp('')
if z == 1
T = [-.9602 -.5770 -.0729 .3771 .6405 .6600 .4609 ... .1336 -.2013 -.4344 -.5000 -.3930 -.1647 .0988 ... .3072 .3960 .3449 .1816 -.0312 -.2189 -.3201]; else if z == 2
T = [0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1]; else
T = [0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0]; end end
张建文 1030319100 张卜南1030319078
神经网络课程设计 神经网络用于机器手臂的控制
plot(P,T,'+');
title('Training Vectors'); xlabel('Input Vector P'); ylabel('Target Vector T'); hold on
% PLOT INITIAL if memsize == 0
wts = zeros(memreq,1); else
wts = zeros(memsize,1); end
for i=1:401
[wts,op(i)] = opcmac(wts,[(P3(i)+2.0)*64],1,iprange,c,width,memsize); end
plot(P3,op,'m');
title('Function Approximation'); xlabel('Input Vector P'); ylabel('Target + Network -'); h = get(gca,'Children'); h = h(1); hold on
pause2(pausetime);
% TRAIN THE NETWORK %==================
% TRAINING PARAMETERS
max_epoch = input('enter maximum number of training epochs ');
epoch = 1; SSE = 1;
while (epoch < max_epoch) & (SSE > 0.02)
for i = 1:21
[wts,netout] = modcmac(wts,[(P(i)+2.0)*64],1,T(i),beta,iprange,c,width,memsize); end for k=1:401
[wts,op(k)] = opcmac(wts,[(P3(k)+2.0)*64],1,iprange,c,width,memsize); end
for i = 1:21
[wts,p]=opcmac(wts,[(P(i)+2.0)*64],1,iprange,c,width,memsize);
张建文 1030319100 张卜南1030319078
神经网络课程设计 神经网络用于机器手臂的控制
neterr(i) = T(i) - p;
end
SSE = sumsqr(neterr);
fprintf('epoch = %d SSE = %5.3f\\n',epoch,SSE); delete(h);
h = plot(P3,op,'m'); drawnow
pause2(pausetime); epoch = epoch + 1; end end
disp('any key to continue'); pause
hold off bar(wts,'r')
title('Network Weights'); xlabel('Weight Number'); ylabel('Weight Value'); if memsize == 0
set(gca,'xlim',[0 memreq]); else
set(gca,'xlim',[0 memsize]);
end
function [wts,op]=opcmac(wts,ip,ipdim,iprange,c,width,memsize) % OP = OPCMAC(WTS,IP,IPRANGE,C,WIDTH,MEMSIZE) HASH=12345; addrs=zeros(c,1);
quantisation=ceil(iprange/width); offset=width/c; ofs=0; op=0;
for i=1:c
address=0; shift=1.0;
for j=1:ipdim
-dress=address+rem((ceil((ip(j)+ofs)/width)),quantisation)*shift; address=address+ceil(ip(j)/width)*shift; shift=shift*quantisation; end;
% address=address+shift*i; if memsize>0
张建文 1030319100 张卜南1030319078