From 7efbd5aca1554c6f90b025faff29e845411024da Mon Sep 17 00:00:00 2001 From: naoaki Date: Wed, 9 Jul 2008 15:41:37 +0000 Subject: [PATCH] Last minutes' change. git-svn-id: file:///home/svnrepos/software/liblbfgs/trunk@16 ecf4c44f-38d1-4fa4-9757-a0b4dd0349fc --- include/lbfgs.h | 2 +- lib/lbfgs.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/lbfgs.h b/include/lbfgs.h index 964fa0c..5223eef 100644 --- a/include/lbfgs.h +++ b/include/lbfgs.h @@ -263,7 +263,7 @@ typedef struct { * (i.e., \ref orthantwise_c != 0). This parameter b (0 <= b < N) * specifies the index number from which the library computes the * L1 norm of the variables x, - * |x| := |x_{b} + x_{b+1} + ... + x_{N}| + * |x| := |x_{b}| + |x_{b+1}| + ... + |x_{N}| . * In other words, variables x_1, ..., x_{b-1} are not used for * computing the L1 norm. Setting b (0 < b < N), one can protect * variables, x_1, ..., x_{b-1} (e.g., a bias term of logistic diff --git a/lib/lbfgs.c b/lib/lbfgs.c index 5524dbf..e9e587b 100644 --- a/lib/lbfgs.c +++ b/lib/lbfgs.c @@ -355,10 +355,12 @@ int lbfgs( } /* - Make sure that the gradients are not zero. + Make sure that the initial variables are not a minimizer. */ vecnorm(&gnorm, g, n); - if (gnorm == 0.) { + vecnorm(&xnorm, x, n); + if (xnorm < 1.0) xnorm = 1.0; + if (gnorm / xnorm <= param->epsilon) { ret = LBFGS_ALREADY_MINIMIZED; goto lbfgs_exit; }