【发布时间】:2016-04-12 08:07:37
【问题描述】:
我正在使用 scipy.optimize.fmin_l_bfgs_b 来解决高斯混合问题。混合分布的均值通过回归建模,其权重必须使用 EM 算法进行优化。
sigma_sp_new, func_val, info_dict = fmin_l_bfgs_b(func_to_minimize, self.sigma_vector[si][pj],
args=(self.w_vectors[si][pj], Y, X, E_step_results[si][pj]),
approx_grad=True, bounds=[(1e-8, 0.5)], factr=1e02, pgtol=1e-05, epsilon=1e-08)
但有时我在信息字典中收到警告“ABNORMAL_TERMINATION_IN_LNSRCH”:
func_to_minimize value = 1.14462324063e-07
information dictionary: {'task': b'ABNORMAL_TERMINATION_IN_LNSRCH', 'funcalls': 147, 'grad': array([ 1.77635684e-05, 2.87769808e-05, 3.51718654e-05,
6.75015599e-06, -4.97379915e-06, -1.06581410e-06]), 'nit': 0, 'warnflag': 2}
RUNNING THE L-BFGS-B CODE
* * *
Machine precision = 2.220D-16
N = 6 M = 10
This problem is unconstrained.
At X0 0 variables are exactly at the bounds
At iterate 0 f= 1.14462D-07 |proj g|= 3.51719D-05
* * *
Tit = total number of iterations
Tnf = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip = number of BFGS updates skipped
Nact = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F = final function value
* * *
N Tit Tnf Tnint Skip Nact Projg F
6 1 21 1 0 0 3.517D-05 1.145D-07
F = 1.144619474757747E-007
ABNORMAL_TERMINATION_IN_LNSRCH
Line search cannot locate an adequate point after 20 function
and gradient evaluations. Previous x, f and g restored.
Possible causes: 1 error in function or gradient evaluation;
2 rounding error dominate computation.
Cauchy time 0.000E+00 seconds.
Subspace minimization time 0.000E+00 seconds.
Line search time 0.000E+00 seconds.
Total User time 0.000E+00 seconds.
我不是每次都收到此警告,但有时会收到此警告。 (大多数会得到 'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_
我知道这意味着在此迭代中可以达到最小值。我用谷歌搜索了这个问题。有人说经常出现是因为目标函数和梯度函数不匹配。但是这里我不提供渐变功能,因为我使用的是 'approx_grad'。
我应该调查哪些可能的原因? “舍入误差主导计算”是什么意思?
======
我还发现对数似然不是单调增加的:
########## Convergence !!! ##########
log_likelihood_history: [-28659.725891322563, 220.49993177669558, 291.3513633060345, 267.47745327823907, 265.31567762171181, 265.07311121000367, 265.04217683341682]
它通常在第二次或第三次迭代时开始减少,即使没有发生“ABNORMAL_TERMINATION_IN_LNSRCH”。不知道这个问题是不是和上一个有关。
【问题讨论】:
-
我也遇到了类似的问题。它们似乎都集中在我给优化器的梯度函数上。您是否 100% 确定您的梯度完全正确?
-
在尝试最大化函数的对数似然时,我遇到了与 L-BFGS 类似的问题。我必须补充一点,我没有传递函数的梯度,而是让 L-BFGS 近似它。有时我可以通过使用 Nelder–Mead 优化器来解决这个问题……你能解决这个问题吗?
-
@muammar,根据我使用 L-BFGS 的经验,它只有在提供显式导数函数时才能正常工作。否则很容易丢失。
标签: optimization machine-learning statistics normal-distribution gradient-descent