From: Chih-Jen Lin Date: Wed, 28 Oct 2020 09:01:51 +0000 (+0800) Subject: Stopping conditon of dual CD method for L1- and L2-loss SVM is changed X-Git-Tag: v242~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=475dfdbae1fa61d6507e9e5c9d5e132b52e00de5;p=liblinear Stopping conditon of dual CD method for L1- and L2-loss SVM is changed Currently the stopping condition is M-m <= \epsilon, where M = max proj_gard(alpha) and m = min proj_grad(alpha). This condition works well in practice, but we must ensure that the following situation does not occur. M, m >> 0 or M,m << 0 but M - m <= \epsilon. From the optimality condition, |M| and |m| must be close to zero. For example, because grad_i f(0) = -1, for all i. M=m= -1 and they satisfy M-m <= \epsilon. Thus we add |M| <=\epsilon and |m| <= \epsilon$ into the stopping condition. In fact we can use only these two inequalities as the stopping condition, but for historical reasons we keep M-m <= \epsilon as the main condition to check. --- diff --git a/linear.cpp b/linear.cpp index 86ec3dd..5426533 100644 --- a/linear.cpp +++ b/linear.cpp @@ -1025,7 +1025,8 @@ static int solve_l2r_l1l2_svc(const problem *prob, const parameter *param, doubl if(iter % 10 == 0) info("."); - if(PGmax_new - PGmin_new <= eps) + if(PGmax_new - PGmin_new <= eps && + fabs(PGmax_new) <= eps && fabs(PGmin_new) <= eps) { if(active_size == l) break;