Can somebody help me to find the error of not having the following code converge on MATLAB? Please note that k means kernel and has its own function.
I tried to implement it using the algorithm in the picture:
My implementation:
while 1
num_changed_alphas = 0;
%step 4
if (Y .* alphas < B)
[Yigi , i_WS] = max(Y .* g)
end
%step 5
if (A < Y .* alphas)
[Yjgj , j_WS] = max(Y .* g)
end
%step 6
if ( (Yigi - Yjgj ) <= eps )
num_changed_alphas = num_changed_alphas + 1;
break;
end
%step 7
lambda = min (B(i_WS) - Y(i_WS) .* alphas(i_WS), Y(j_WS) .* alphas(j_WS) - A(j_WS) );
lambda = min (lambda, (Yigi - Yjgj) ./ (K(i_WS,i_WS) + K(j_WS,j_WS) - 2* K(j_WS,i_WS)) );
g = sum (g - lambda .* Y .* K (:,i_WS) + lambda .* Y .* K (:,j_WS));
alphas = alphas + Y * lambda;
fprintf('.');
dots = dots + 1;
if dots > 75
dots = 0;
fprintf('\n');
end
if exist('OCTAVE_VERSION')
fflush(stdout);
end
end %while
