📄 mexicanhat.m
字号:
% ==========================================================
%
% Neural Networks A Classroom Approach
% Satish Kumar
% Copyright Tata McGraw Hill, 2004
%
% MATLAB code that implements the Mexican hat
% network connectivity
% Reference: Table 12.6;Page 551
%
% ==========================================================
% Mexican Hat Network Simulation
leradius = 5; % Excitation radius
liwidth = 10; % Inhibition radius
interactlen = leradius + liwidth +1;
max = 10; % Maximum signal value
excit = 0.1; % a
inhibit = -0.05; % b
feedback = 1.5; % gamma
for j=1:50 % Generate the Mexican hat connectivity
for i=1:50 % 50 x 50 weights
indexdif = abs(j-i);
if (indexdif < interactlen)
if (indexdif < leradius+1)
w(j,i) = excit;
else
w(j,i) = inhibit;
end
else
w(j,i) = 0;
end
end
end
index=1:1:50;
input = sin(pi.*index/50); % Set up input vector
s=zeros(50); % Initialize signals
figure;
subplot(1,2,1);
hold on
for t=1:15
for i =1:50 % Compute activations
activation(i) = input(i);
for j=1:50
activation(i) = activation(i) + feedback*w(j,i)*s(j);
end
end
for i=1:50 % compute signals
if (activation(i) > max) s(i) = max;
elseif (activation(i) < 0) s(i) = 0;
else s(i) = activation(i);
end
end
plot(index, s);
end
xlabel('Neuron index');
ylabel('Signal strength');
title('(a)');
subplot(1,2,2);
hold on
feedback = 0.75;
s = zeros(50);
for t=1:15
for i =1:50
activation(i) = input(i);
for j=1:50
activation(i) = activation(i) + feedback*w(j,i)*s(j);
end
end
for i=1:50
if (activation(i) > max) s(i) = max;
elseif (activation(i) < 0) s(i) = 0;
else s(i) = activation(i);
end
end
plot(index, s);
end
axis([0 50 0 5]);
xlabel('Neuron index');
ylabel('Signal strength');
title('(b)');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -