📄 avq_dat.m
字号:
echo off% avq_dat.m%% Adaptive Vector Quantisation with an autoassociative two-layer feedforward% neural network.% For a pattern space consisting of 500 two-dimensional Gausian normal % distributed pattern vectors with variance 1 and centroids or modes at% (-1,1), (1,1), (1,-1), (-1,-1).% Different unsupervised learning algorithm can be applied to the problem.%% Reference:% Kong, Kosko : 'Differential Competive Learning for Centroid Estimation% and Phoneme Recognition'. % IEEE Transcactions on Neural Networks, Vol.2, No.1, Jan.1991% pp.118-124%% FSTB - Fuzzy Systems Toolbox for MATLAB% Copyright (c) 1993-1996 by Olaf Wolkenhauer% Control Systems Centre at UMIST% Manchester M60 1QD, UK%% 20-May-1994dec=input('Generating new training pattern ? y/n [n] : ','s');if dec=='y', % Generating 4x500 Gaussian-normal distributed pattern vectors, with % centroids or modes at (-1,1), (1,1), (1,-1), (-1,-1). spc=500; x1=randn(1,spc)-ones(1,spc); y1=randn(1,spc)+ones(1,spc); x2=randn(1,spc)+ones(1,spc); y2=randn(1,spc)+ones(1,spc); x3=randn(1,spc)+ones(1,spc); y3=randn(1,spc)-ones(1,spc); x4=randn(1,spc)-ones(1,spc); y4=randn(1,spc)-ones(1,spc); samples=[[x1';x2';x3';x4'],[y1';y2';y3';y4']];end;dec=input('Pattern vector plot ? y/n [n] : ','s');if dec=='y', plot(samples(:,1),samples(:,2),'.'); title('training pattern vectors'); ylabel('centroids: (-1,1) (1,1) (1,-1) (-1,-1)');end;clear x1 x2 x3 x4 y1 y2 y3 y4p=4;c=1;wii=1;wij=-1;disp('');disp(['p=',num2str(p),' c=',num2str(c),' wii=',num2str(wii),' wij=',...num2str(wij)]);dec=input('Any changes ? y/n [n] : ','s');if dec=='y', disp('type return to continue.'); keyboard; end;dec=input('new figure ? y/n [n] : ','s');if dec=='y', figure; else, clf; end;%axis([-3 3 -3 3]);grid on; xlabel('x');ylabel('y');%title('convergence of quantization vectors mj(t)');%hold ondec=input('Random mix of sample pattern ? y/n [y] : ','s');if isempty(dec), dec=='y'; end;if dec=='y', rands=randperm(length(samples));end;dec=input('UCL, DCL - algorithm ? u/d : ','s');subplot(2,2,4); axis([-3 3 -3 3]); hold onxlabel('x');ylabel('y'); title('quantisation vector convergence :');%set(gca,'DrawMode','fast'); %set(gca,'EraseMode','none');if dec=='u', [y2,m2x,m2y]=ucl(samples,p,c,wii,wij,rands); met='ucl';elseif dec=='d', [y2,m2x,m2y]=dcl(samples,p,c,wii,wij,rands); met='dcl';end;t=1:1:length(samples);subplot(2,2,2);plot(t,m2x,t,m2y);ylabel('M(2,2)=y M(1,2)=x');grid onsubplot(2,2,1);plot(y2);ylabel('yt1(2)'); xlabel('training time');%subplot(2,2,4);plot(m2y);ylabel('M(2,2) = y'); grid onsubplot(2,2,3);axis([0 1 0 1]);set(gca,'Visible','off');text(0,0,['wii = ',num2str(wii)]);text(0,0.2,['wij = ',num2str(wij)]);text(0,0.4,['pattern = ',num2str(length(samples))]);text(0,0.6,'ct = 0.1(1-t/pattern)');text(0,0.8,['c = ',num2str(c)]);text(0,1,[met,' algorithm']);clear p c spc dec wii wij met % packecho on
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -