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.

65 lines
2.1 KiB
Matlab

function expts_working_memory()
%Demonstration of working memory in a PC/BC-DIM network
%define the network
values{1,1}=[-170:5:170];
centres=[-170:10:170];
W{1}=[];V{1}=[];
for c=centres
W{1}=[W{1};code(c,values{1,1},10,0,1),1];
V{1}=[V{1};code(c,values{1,1},10),1];
end
W{1}=W{1}./2;
[n,m]=size(W{1});
interconnects{1,1}=[];
partitions{1,1}=[1:length(values{1,1})];
partitions{1,2}=[1+length(values{1,1})];
values{1,2}=1;
stdx=15;
%define the sequence of inputs to the network
xstep{1}=[code(80,values{1,1},stdx),1]'; its(1)=50; %encode memory 1
xstep{2}=[0.*code(80,values{1,1},stdx),1]'; its(2)=250; %retain memory 1
xstep{3}=[code(-80,values{1,1},stdx),1]'; its(3)=50; %encode memory 2
xstep{4}=[0.*code(-80,values{1,1},stdx),1]'; its(4)=100; %retain memory 2
xstep{5}=[0.*code(80,values{1,1},stdx),0]'; its(5)=50; %clear memory
xstep{6}=[0.*code(80,values{1,1},stdx),1]'; its(6)=50; %remember nothing!
%show state of network after each step in the sequence
y=[];
for step=1:length(xstep)
[y,e,r]=dim_activation_hierarchical(W,{xstep{step}},V,interconnects,y,its(step));
figured(step), clf,
plot_network({xstep{step}},r,y,partitions,values,[],1);
print('-dpdf',['working_memory',num2str(step),'.pdf'])
end
%show reconstuction neuron responses every 50 iterations
cumits=[0,cumsum(its)];
for step=1:length(xstep)
for t=cumits(step)+[1:its(step)]
x{1}(:,t)=xstep{step};
end
end
[y,e,r,ytrace,rtrace]=dim_activation_hierarchical(W,x,V,interconnects,[],cumits(end)+1);%<-reset network activity
figured(101),clf
k=0;
for t=550:-50:50
k=k+1;
axes('Position',[0.67-0.05*k, 1-0.089*k, 0.12, 0.078]);
plot(x{1}(:,t),'Color','k','LineWidth',2);
axis([partitions{1,1}(1),partitions{1,1}(end),0,1]);
set(gca,'YTick',[],'XTick',[]);
text(0,0.4,['t=',int2str(t)],'Units','normalized','HorizontalAlignment','right');
axes('Position',[0.8-0.05*k, 1-0.089*k, 0.12, 0.078]);
plot(rtrace{1}(:,t),'Color',[0,0.65,0],'LineWidth',2);
axis([partitions{1,1}(1),partitions{1,1}(end),0,0.85]);
set(gca,'YTick',[],'XTick',[]);
end
set(gcf,'PaperSize',[8 6.5],'PaperPosition',[0.5 0.5 7.5 6],'PaperOrientation','Portrait');
print('-dpdf',['working_memory_trace.pdf'])