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.
35 lines
809 B
Matlab
35 lines
809 B
Matlab
function [y,e,r]=dim_activation(W,x,V,y)
|
|
[n,m]=size(W);
|
|
[nInputChannels,batchLen]=size(x);
|
|
|
|
%set parameters
|
|
epsilon1=1e-6;
|
|
epsilon2=1e-3;
|
|
iterations=50;
|
|
%maxIterations=1000;
|
|
|
|
if nargin<4 || isempty(y)
|
|
y=zeros(n,batchLen,'single'); %initialise prediction neuron outputs
|
|
end
|
|
if nargin<3 || isempty(V)
|
|
%set feedback weights equal to feedforward weights normalized by maximum value
|
|
V=bsxfun(@rdivide,W,max(1e-6,max(W,[],2)));
|
|
end
|
|
V=V'; %avoid having to take transpose at each iteration
|
|
|
|
%iterate to find steady-state response to input t=0;
|
|
%ediff=Inf;eprev=0;t=0;
|
|
%while t<maxIterations && ediff>0.01
|
|
% t=t+1;
|
|
for t=1:iterations
|
|
%update responses
|
|
r=V*y;
|
|
%e=x./max(epsilon2,r);
|
|
e=x./(epsilon2+r);
|
|
%y=max(epsilon1,y).*(W*e);
|
|
y=(epsilon1+y).*(W*e);
|
|
|
|
%ediff=sum(abs(e-eprev));
|
|
%eprev=e;
|
|
end
|