⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compet.m

📁 Martin T.Hagan等著,戴葵等译,神经网络设计,机械工业出版社,一书的所有例程
💻 M
字号:
function a = compet(n,b)
%COMPET Competitive transfer function.
%	
%	COMPET(N)
%	  N - SxQ matrix of net input (column) vectors.
%	Returns the output vectors with 1 where each net input
%	  vector had its maximum value, and 0 elsewhere.
%	
%	EXAMPLE: n = [0.0; 0.2; 0.6; 0.1];
%	         a = compet(n)
%	
%	COMPET(Z,B) ...Used when Batching.
%	  Z - SxQ Matrix of weighted input (column) vectors.
%	  B - Sx1 Bias (column) vector.
%	Returns results of applying competition to net input values
%	  found by adding B to each column of Z.%	

% Mark Beale, 1-31-92
% Revised 12-15-93, MB
% Copyright (c) 1992-94 by the MathWorks, Inc.
% $Revision: 1.1 $  $Date: 1994/01/11 16:23:53 $

if nargin < 1,error('Not enough arguments.'); end

[S,Q] = size(n);

[nr,nc] = size(n);
if nargin==2
  n = n + b*ones(1,nc);
end

if nr == 1
  a = ones(S,Q);
else
  a = sparse([],[],[],nr,nc,nc);
  y = max(n);
  for i=1:nc
    ind = find(n(:,i) == y(i));
    a(ind(1),i) = 1;
  end
end

⌨️ 快捷键说明

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