很抱歉,如果代码很草率。该代码应该从激发速率(十字形,正方形等)的记忆向量建立一个Hopfield网络,在膜电位和激发速率之间转换函数f(ui)= tanh(beta * ui)并使用演化进化规则表明。但由于某些原因它无法正常工作:记忆不被检索,而是图像以某种方式消失。请帮忙。
w = zeros(100);
beta = 4;
% Memory 1: a cross
m1 = ones(10,10);
m1(:, 4) = 0;
m1(4, :) = 0;
init = m1(1:4,:);
m1 = (m1*2-1);
% Memory 2: a square
m2 = ones(10,10);
m2(5:7, 5:7) = 0;
m2 = (m2*2-1);
% Memory 3: a hollow square
m3 = ones(10,10);
m3(:, 1) = 0;
m3(:, 10) = 0;
m3(1, :) = 0;
m3(10, :) = 0;
m3 = (m3*2-1);
% build weight network
for i = 1:100
for j = 1:100
if i ~= j
w(i,j) = w(i,j) + m1(i) * m1(j) + m2(i) * m2(j) + m3(i) * m3(j);
end
end
end
% Initial condition
f1 = [init; rand(6,10)];
f1 = f1*2-1;
f1 = 0.9*f1;
%invert to produce membrane potential
u1 = atanh(f1)/beta;
% evolve according to equation 1
weight = 0;
rate = 0;
evolve = u1;
for t = 1:1
u1 = evolve;
for i = 1:10
for j = 1:10
weight = w(i,:); % weighted connection w/ every other neuron
rate = tanh(beta*u1(:));
evolve(i,j) = u1(i,j) + .05* (-u1(i,j) + (weight * rate));
end
end
end
u1 = evolve;
f1 = tanh(beta * u1);
imshow(reshape(f1, 10, 10), [-1 , 1], 'InitialMagnification', 'fit');