cpann_assign_neuron.m

来自「Kohonen and CPANN toolbox是开发的一个MATLAB工具箱」· M 代码 · 共 42 行

M
42
字号
function neurons_ass = cpann_assign_neuron(W_out,method,thr)

% cpann_assign_neuron assigns each neuron to a class
%
% neurons_ass = cpann_assign_neuron(W_out,method,thr);
%
% input:
%   W_out           unfolded CPANN weights [size*size x c]
%   method          method of assignation
%                   if method = 1 -> maximum weigth
%                   if method = 2 -> maximum difference over threshold
%                   if method = 3 -> maximum weigth over threshold
%   thr             threshold for method 2 and 3
% 
% output:
%   neurons_ass     assignation of neurons [size x size]
%
% see the HTML HELP files (help.htm) for details 

for k = 1:size(W_out,1)
    for j = 1:size(W_out,2)
        if method == 1      % maximum weight
            [m,where] = max(W_out(k,j,:));
            neurons_ass(k,j) = where;
        elseif method == 2  % maximum difference with threshold 
            [val,pos] = sort(squeeze(W_out(k,j,:)));
            delta_class = val(end) - val(end - 1);
            if delta_class > thr(2)
                neurons_ass(k,j) = pos(end);
            else
                neurons_ass(k,j) = 0;
            end
        elseif method == 3  % maximum weight with threshold 
            [m,where] = max(W_out(k,j,:));
            if m > thr(3)
                neurons_ass(k,j) = where;
            else
                neurons_ass(k,j) = 0;
            end            
        end
    end
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?