1 |
- function mT1 = updateM_v4(mT, yT, dT1, inhibCap, etaM, maxM)
%%%%%
% run this for each timestep to update weight mat. for next timestep
% inputs are:
% mT, lateral weight mat for given timestep
% yT, outputs for timestep
% dT1 is memorized activity of neuron up to and including next timestep
% (ie, updateD must be run before this)
%
% output is:
% mT1, output lateral weights matrix for next timestep
%%%%%
m = size(mT,1); %num out
mT1 = zeros(size(mT));
for idx = 1:m
for jdx = 1:m
if idx ~= jdx
t1 = mT(idx,jdx); %term 1 of m update
% t2n = yT(idx) * (yT(jdx) - (mT(idx,jdx)*yT(idx))); %num of t2
t2n = etaM* yT(idx) * yT(jdx); % - (mT(idx,jdx)*yT(idx))); %num of t2
t2d = 1;%dT1(idx); %denom of t2
t2 = t2n/t2d; %term 2 of m update
mT1(idx, jdx) = (t1 + t2);
else
mT1(idx, jdx) = 0;
end
end
end
mT1(mT1<=0) = eps; % synapses don't die (negs not okay)
mT1(mT1>maxM) = maxM; %max weight for single synapse
for idx = 1:m
for jdx = 1:m
if idx == jdx %change here for upper triang
mT1(idx, jdx) = 0; %BUT DIAG STILL 0
end
end
if inhibCap > 0 %if input cap is 0, no cap
mT1(idx,:) = mT1(idx,:) ./ (norm(mT1(idx,:))/inhibCap); %normalize inhib to each
end
end
if isnan(sum(mT1(:)))
mT1(isnan(mT1)) = 0;
end
end
|