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.
45 lines
1.0 KiB
Matlab
45 lines
1.0 KiB
Matlab
function [y,e,ytrace,W,V,U]=dim_activation_recurrent(W,xtrace,y,iterations,V,U)
|
|
[n,m]=size(W);
|
|
[nInputChannels,z]=size(xtrace);
|
|
|
|
%set parameters
|
|
epsilon1=1e-5;
|
|
epsilon2=1e-3;
|
|
|
|
if nargin<3 || isempty(y),
|
|
%initialise prediction neuron outputs
|
|
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=bsxfun(@rdivide,W,(1e-9+max(W,[],2)));
|
|
U=V;
|
|
end
|
|
|
|
for t=1:iterations
|
|
%define inputs: temporally changing values are used (if these are provided), and
|
|
%previous output values are copied to provide recurrent input
|
|
x=xtrace(:,min(t,z));
|
|
x(nInputChannels+1:nInputChannels+n)=y;
|
|
|
|
%update error and prediction neuron responses
|
|
e=min(1,x)./(epsilon2+(V'*y));
|
|
y=(epsilon1+y).*(W*e);
|
|
|
|
%record activation history - if required
|
|
if nargout>2
|
|
ytrace(:,t)=y;
|
|
end
|
|
|
|
%perform learning at every step - if required
|
|
if nargout>3
|
|
[W,V]=dim_learn(W,V,y,e);
|
|
end
|
|
if nargout>5
|
|
U=dim_learn_feedback(U,y,x);
|
|
end
|
|
end
|