You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

#### 51 lines 2.3 KiB Matlab Raw Permalink Blame History

 ```function jets_sharks() ``` ```%load weights for prediction neurons representing individuals from inputs representing properties: ``` ```%Jet Shark 20s 30s 40s jh col hs sing married divorced pusher burglar bookie ``` ```W=load('jets_sharks_weights.txt'); ``` ``` ``` ```%add name units - one for each individual ``` ```W=[eye(27,27),W]; ``` ```[n,m]=size(W) ``` ``` ``` ```%normalise weights ``` ```%W=bsxfun(@rdivide,W,max(1e-6,sum(W,2))); ``` ``` ``` ```X=zeros(27+14,9); ``` ```%define input patterns - Handbook ``` ```X(22,1)=1; %retrival by name ('ken') ``` ```X(27+2,2)=1;X(27+3,2)=1; %retreval by unique combination of attributes ('ken' from 'shark', '20s') ``` ```X(27+3,3)=1;X(27+6,3)=1; %retreval by nonunique combination of attributes ``` ```X(27+2,4)=1;X(27+3,4)=1;X(27+6,4)=1;X(27+9,4)=1;X(27+13,4)=1; %retreval with wrong information (ken's attributes but with JuniorHigh instead of HighSchool. ``` ```X(27+1,5)=1; %what are jets like? ``` ```X(27+12,6)=1; %who are pushers? ``` ``` ``` ```%define input patterns - Bechtel and Abrahamsen ``` ```X(1,7)=1; %retrival by name ('art') ``` ```X(27+2,8)=1; %what are sharks like? ``` ```X(27+3,9)=1;X(27+12,9)=1; %retreval by combination of attributes (20s + pusher) ``` ``` ``` ```%present each input to the network in turn and record the results ``` ```for k=1:size(X,2) ``` ``` x=X(:,k); ``` ``` x=x./sum(x); ``` ``` [y,e,r]=dim_activation(W,x); ``` ``` ``` ``` figure(k),clf ``` ``` plot_result(x,r), ``` ``` print(gcf, '-dpdf', ['jets_sharks',int2str(k),'.pdf']); ``` ```end ``` ``` ``` ``` ``` ```function plot_result(x,r) ``` ``` ``` ```attributes=[' Art';' Al';' Sam';' Clyde';' Mike';' Jim';' Greg';' John';' Doug';' Lance';' George';' Pete';' Fred';' Gene';' Ralph';' Phil';' Ike';' Nick';' Don'; ``` ```' Ned';' Karl';' Ken';' Earl';' Rick';' Ol';' Neal';' Dave'; ``` ```' Jet';' Shark';' 20s';' 30s';' 40s';' JnrHigh';' College';' HighSch';' Single';' Married';'Divorced';' Pusher';' Burglar';' Bookie']; ``` ``` ``` ```maxsubplot(3,1,2,0.1);bar(x,'k'),axis([0.5,length(x)+0.5,0,1.05]) ``` ```set(gca,'XTick',[1:length(x)],'XTickLabel',[],'FontSize',12); ``` ```text([1:length(x)]-0.06,-0.03.*ones(1,length(x)),attributes,'HorizontalAlignment','right','VerticalAlignment','middle','rotation',90); ``` ```maxsubplot(3,1,3,0.1);bar(r,'FaceColor',[0,0.7,0]),ax=axis;axis([0.5,length(x)+0.5,0,1.05]) ``` ```set(gca,'XTick',[1:length(x)],'XTickLabel',[],'FontSize',12); ``` ``` ``` `set(gcf,'PaperSize',[20 6],'PaperPosition',[0 0 20 6],'PaperOrientation','Portrait');`