我正在尝试使用以下代码使用 fmin_l_bfgs_b 算法的 SciPy 实现:
imgOpt, cost, info = fmin_l_bfgs_b(func, x0=img, args=(spec_layer, spec_weight, regularization), approx_grad=1,bounds=constraintPairs, iprint=2)
变量 img 只是一个包含 784 个像素的向量,其中所有角都设置为 0,中间部分在 0 到 255 之间随机初始化。角的边界是 (0,0),中间部分的边界是 (0, 255 )。该函数是我的神经网络中隐藏神经元的加权输入。这一切都不应该是特别的。但是,当我运行算法时,它会立即停止,因为投影梯度为零。如何帮助算法找到合适的梯度估计,使其不会立即停止?
输出:
RUNNING THE L-BFGS-B CODE
it = iteration number
nf = number of function evaluations
nseg = number of segments explored during the Cauchy search
nact = number of active bounds at the generalized Cauchy point
sub = manner in which the subspace minimization terminated:
con = converged, bnd = a bound was reached
itls = number of iterations performed in the line search
stepl = step length used
tstep = norm of the displacement (total step)
projg = norm of the projected gradient
f = function value
* * *
Machine precision = 2.220D-16
N = 784 M = 10
it nf nseg nact sub itls stepl tstep projg f
0 1 - - - - - - 0.000D+00 1.694D+00
CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL
Total User time 0.000E+00 seconds.