dualmaxsparsealignmentlm.m
来自「a function inside machine learning」· M 代码 · 共 32 行
M
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 + -
显示快捷键?