dualmaxsparsealignmentlm.m.svn-base

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

SVN-BASE
32
字号
function [b, tau] = dualMaxSparseAlignmentLM(K, Kj, Y, Yj, previousTau, previousB, startExample)
%A function to compute the maximum sparse target alignment vector between partial kernel matrix
%K and vector y. Works on chunks of cols of the kernel matrix, i.e. the whole kernel matrix need not be 
%in memory. 

%We just use the example with the highest alignment

numPartialExamples = size(Kj, 2); 
numTotalExamples = size(Kj, 1); 
columnIndices = (startExample:startExample+numPartialExamples-1)';

normSquarePreviousTau = previousTau'*previousTau; 

if normSquarePreviousTau ~= 0 
    previousAlignment = (previousTau'*Yj)^2/(normSquarePreviousTau*(Y'*Y)); 
else 
    previousAlignment = -1; 
end

[alignments, bs] = sparseAlignments(K, Kj, Y, Yj, columnIndices); 

[maxAlignment, i] = max(abs(alignments)); 

if maxAlignment > previousAlignment
    b = zeros(numTotalExamples, 1); 
    b(i+startExample-1) = bs(i);
    tau = Kj(:, i)*bs(i);
else
    b = previousB; 
    tau = previousTau; 
end

⌨️ 快捷键说明

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