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.

49 lines
1.4 KiB
Matlab

function [performance]=test_response(X,W,V,U)
iterations=200;
%for each test input
for k=1:size(X,2)
%calculate response of network
if iscell(W) %for a hiearchical network
x{1}=X(:,k);
numStages=length(W);
for stage=1:numStages+1
y{stage}=[];
z{stage}=[];
end
for t=1:iterations
for stage=1:numStages
[y{stage},e{stage},z{stage}]=dim_activation_step(...
W{stage},x{stage},y{stage},V{stage},U{stage},z{stage+1});
x{stage+1}=y{stage};%input to next stage equal to output from this
end
end
yout(:,k)=y{numStages};
else %for a single DIM network
x=X(:,k);
yout(:,k)=dim_activation(W,x,[],iterations,V);
end
end
[resp,node]=max(yout); %locate nodes giving maximum response to each input
disp(['max response=',num2str(max(resp)),' min response=',num2str(min(resp))]);
reps=unique(node); %locate nodes which only respond to one input
performance=length(reps)/length(resp);
disp(['response represents ', num2str(performance*100), '% of all possible patterns ']);
%plot node response verses test pattern number
%determine how to sort responses (sorting based on maximum responses only)
clf
ytmp=yout;
ytmp(find(ytmp<min(resp)))=0;
[poo,sortorder]=sortrows(ytmp);
imagesc(yout(sortorder,:),[0,1])
xlabel('component')
ylabel('node')
title('responses generated by each component')
set(gca,'YTick',[1:length(sortorder)],'YTickLabel',sortorder);
drawnow