📄 art.m
字号:
% ==========================================================
%
% Neural Networks A Classroom Approach
% Satish Kumar
% Copyright Tata McGraw Hill, 2004
%
% MATLAB code that implements the ART 1 algorithm
% Reference: Table 11.4;Page 505
%
% ==========================================================
% ART 1 ALGORITHM FOR BINARY PATTERNS
% Classify the following four 5-dimensional vectors
% Use L=2, and set the vigilance as desired.
n = 5; % Initialize n,m, and rho
m = 1;
rho = 0.3;
out = ones(m,n); % Outstar initalized to 1
inwt = 2/(1+n); % Initial value of each instar weight
in = (inwt*out)'; % Instar set up
p=[1 1 1 0 0 % Store the patterns
1 1 0 0 0
0 0 0 0 1
0 0 0 1 1];
q = 4; % q patterns to be classified
newnodeflag = 1; % Get into the loop
while(newnodeflag==1) % New node added to F2...
newnodeflag =0; % reset the newnode flag...
for k = 1:q % for each pattern
outstarlearn = 0 % reset the outstar learnt flag
index = ones(1,m) % all nodes can compete
y = p(k,:)*in % compute F2 activations
while(sum(index) ~= 0) % some nodes not reset
[maxy,windex] = max(y) % find index of winner
s = out(windex,:).*p(k,:) % compute F1 signals
M = sum(s)/sum(p(k,:)) % Find ratio of signals, M
if M > rho % check ratio with vigilance
out(windex,:) = s % if ok then learn
in(:,windex) = (2/(1+sum(s)))*s'
outstarlearn = 1 % set learnt flag
break % exit
else
index(windex) = 0 % else reset the index entry
y(windex) = -1 % suppress activity of M
end % (they can never be negative!)
end
% No node could classify
if ((~outstarlearn) & sum(index) == 0)
m = m+1 % add a new node
out(m,:)=p(k,:) % Learn
in(:,m)=p(k,:)'*(2/(1+sum(p(k,:))))
newnodeflag = 1 % set the new node added flag
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -