1999 Spg EE 380L Artificial Neural Systems

Unique # 14945


Problem 3

%----------    Experiment parameters
sigma        = 1;    % width of centers
nhidden        = 20;    % # of centers
maxepochs    = 50;    % for clustering (finding centers)
showerr        = 1;    % whether to display -Likelihood while clustering
%--------------------    RBF init
options(1)    = showerr;
options(5)    = 1;
options(14)    = maxepochs;
net        = rbf(d,nhidden,dy,'gaussian');
%--------------------    RBF train
net        = rbftrain(net,options,tin',tout');
%-----    reset RBF widths to sigma and recompute linear weights
%-----    **** here sigma is set to all ones, but in your code you must
%-----    evaluate the distance from each center, net.c(j) to the nearest center and set
%-----    net.wi(j) equals this distance
net.wi    = sigma*ones(size(net.wi));

%---------- with the updated weights, we feed the inputs into the RBF and obtain the new activations corresponding
%        to each input vector. y here is obtained using the old weights net.w2, net.b2, which was derived based on the old sigmas
%        net.wi and therefore is incorrect.
[y,act]    = rbffwd(net,tin');
%---------- now we recompute the new W matrix comprising net.w2 and net.b2 by doing a pseudo inverse using the new
%            activation functions. The rows of ones correspond to bias inputs (constant activation) weighted by an extra row in the
%            W matrix (denoted here explicitly by net.b2)
temp    = pinv([act ones(tsize,1)])*tout';
net.w2    = temp(1:nhidden,:);
net.b2    = temp(nhidden+1,:);
%--------------------    RBF test/validate
touthat    = rbffwd(net,tin')';

Problem 5

w    = initsm(range,100);    % initialize 100 weight vectors whose min-max values is specified by range, in this case [-1 1]
m    = nbman(10,10);        % initialize 10 x 10 grid structure
plotsm(w,m);                     % plot the initial SOM in 2-D
tp    = [20 750 1];             % parameter : maximum of 750 epochs
w    = trainsm(w,m,sdata,tp);    % train the SOM
plotsm(w,m);                     % plot the trained SOM in 2-D