%% Script file: Associations with Widrow-Hoff %% First, the data (and plots) T1=[1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1]; T2=[-1 1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1]; G1=[1 1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 1 -1]; G2=[-1 1 1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 1]; F1=[1 1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1]; F2=[-1 1 1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1]; gg=colormap(gray); gg=gg(end:-1:1,:); subplot(2,3,1) imagesc(T1) colormap(gg) subplot(2,3,2) imagesc(G1) subplot(2,3,3) imagesc(F1) subplot(2,3,4) imagesc(T2) subplot(2,3,5) imagesc(G2) subplot(2,3,6) imagesc(F2) %% Next, the actual training and results: X=[T1(:) T2(:) G1(:) G2(:) F1(:) F2(:)]; X=X'; %Data should be number of pts (6) by dimension (16) T=[60 60 0 0 -60 -60]; T=T'; %Targets should be a column. lr=0.06; % alpha is 0.03 iters=60; %60 times through the data [W,b,EpochErr]=wid_hoff1(X,T,lr,iters); figure(2) plot(EpochErr); %% Example of using the network to classify the points. Ans1=W*X(3,:)'+b %Should be zero for G Ans2=W*X(6,:)'+b %Should be about -60 for F