Update lbfgs.c

This commit is contained in:
张壹 2019-10-22 16:13:15 +08:00
parent 38c0f38d72
commit 1f5145a580

View File

@ -514,6 +514,9 @@ int lbfgs(
Convergence test.
The criterion is given by the following formula:
|g(x)| / \max(1, |x|) < \epsilon
x的模小于1的话反而会放大模型梯度的模x的模长大于等于1.00线
00
*/
if (xnorm < 1.0) xnorm = 1.0;
if (gnorm / xnorm <= param.epsilon) {
@ -526,6 +529,7 @@ int lbfgs(
Test for stopping criterion.
The criterion is given by the following formula:
|(f(past_x) - f(x))| / f(x) < \delta
0
*/
if (pf != NULL) {
/* We don't test the stopping criterion while k < past. */
@ -589,7 +593,7 @@ int lbfgs(
} else {
vecncpy(d, pg, n);
}
// 此处开始迭代
// 此处开始迭代 利用双重循环计算H^-1*g得到下降方向
j = end;
for (i = 0;i < bound;++i) {
j = (j + m - 1) % m; /* if (--j == -1) j = m-1; */