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.
46 lines
1.0 KiB
Matlab
46 lines
1.0 KiB
Matlab
function [y,e,W,V,U]=dim_activation(W,xtrace,y,iterations,V,U,trace)
|
|
[n,m]=size(W);
|
|
[nInputChannels,z]=size(xtrace);
|
|
|
|
%epsilon1=1e-4;epsilon2=0.1;
|
|
epsilon1=1e-5;epsilon2=1e-3;
|
|
%epsilon1=1e-9;epsilon2=0.1;
|
|
%epsilon1=1e-9;epsilon2=1e-9;
|
|
|
|
if nargin<3 || isempty(y), %initialise prediction neuron outputs to zero
|
|
y=zeros(n,1,'single');
|
|
end
|
|
|
|
if nargin<4, iterations=25; end
|
|
|
|
if nargin<5 || isempty(V),
|
|
%set feedback weights equal to feedforward weights normalized by maximum value
|
|
%V=W./(1e-9+(max(W')'*ones(1,m)));
|
|
V=bsxfun(@rdivide,W,(1e-9+max(W,[],2)));
|
|
U=V;
|
|
end
|
|
if nargin<7, trace=0; end
|
|
|
|
yTrace=[];
|
|
yMean=y;
|
|
for t=1:iterations
|
|
x=xtrace(:,min(t,z));
|
|
|
|
%update responses
|
|
e=min(1,x)./(epsilon2+(V'*y));
|
|
%e=(epsilon2+x)./(epsilon2+(V'*y));
|
|
y=(epsilon1+y).*(W*e);
|
|
%yTrace=[yTrace,y];
|
|
|
|
yMean=yMean+y;
|
|
%perform learning at every step - if required
|
|
if nargout>2
|
|
[W,V]=dim_learn(W,V,y,e);
|
|
end
|
|
if nargout>4
|
|
U=dim_learn_feedback(U,y,x);
|
|
end
|
|
end
|
|
if trace, y=yMean./iterations; end
|
|
%figure(5), plot(yTrace'), drawnow;
|
|
%yTrace |