sparsealignments.m.svn-base

来自「a function inside machine learning」· SVN-BASE 代码 · 共 32 行

SVN-BASE
32
字号
function [alignments, bs] = sparseAlignments(K, Kj, Y, Yj, columnIndices)
%Compute the alignments of the columns of the kernel matrix. The variable
%called bs is the values of the selected b's  

if (nargin ~= 5)
    fprintf('%s\n', help(sprintf('%s', mfilename)));
    error('Incorrect number of inputs - see above usage instructions.');
end

numExamples = size(K, 1); 
numColumns = size(K, 2); 
tol = 10^6; 

warning('off','MATLAB:divideByZero');
invNormVector = 1./sum(Kj.^2, 1)';  
warning('on','MATLAB:divideByZero');

infiniteIndices = find(invNormVector > tol); 
invNormVector(infiniteIndices) = 0;

%This bit is slow so can remove it (but then the results aren't strictly
%alignments) 
%YY = Y'*Y;
%YTerm = sqrt(sum(sum(YY.^2, 1))); 

YK = (Y'*Kj);
%alignments = abs(sum(YK.^2, 1)' .* invNormVector)/YTerm; 
alignments = abs(sum(YK.^2, 1)' .* invNormVector);
bs = sqrt(invNormVector); 


⌨️ 快捷键说明

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