%---------- uses MATLAB Neural Network Toolbox %---------- Version 2.0.4 02-Jun-1997 % assume % % sdata is the 4x150 iris input % outpt is the 1x150 iris class labels % % lans_cplotmd is a LANS library function which plots class data range = [min(sdata')' max(sdata')']; w = initsm(range,100); m = nbman(10,10); depochs = [1 5 10 100 1000 10000]; sumepochs = 0; for pic=1:length(depochs) neigh = 1*exp(-sumepochs/10000); maxepochs = depochs(pic)-sumepochs; tp = [20 maxepochs neigh]; w = trainsm(w,m,sdata,tp); sumepochs = sumepochs + maxepochs; %---------- compete (find nearest neuron) neighborhoodsize = 0; o = simusm(sdata,w,m,neighborhoodsize); [neuron n] = find(o~=0); %---------- compute position on feature grid y = ceil(neuron/10); x = neuron-(y-1)*10; ldata = [x y outpt']'; noise = .1*randn(2,length(neuron)); ldata(1:2,:)= ldata(1:2,:)+noise; %---------- plot clf; lans_cplotmd(ldata); axis([0.5 10.5 0.5 10.5]) grid on; box on; %legend('2','3','1'); title(sprintf('[%d] o-class 1 +-class 2 *-class 3',sumepochs)); drawnow filename = sprintf('som%d.ps',sumepochs); com = ['print -dpsc ' filename]; eval(com); pause end