【问题标题】:L-BFGS from RISO not workingRISO 的 L-BFGS 不工作
【发布时间】:2014-01-09 12:15:49
【问题描述】:

我正在测试 RISO 的 L-BFGS 库的实现,以实现 Java 中逻辑回归的函数最小化。 Here 是我正在使用的类的链接。

为了测试这个库,我试图最小化这个函数:

f(x) = 2*(x1^2) + 4*x2 + 5

该库需要我实现的目标和梯度函数如下:

   /**
      The value of the objective function, given variable assignments
      x. This is specific to your problem, so you must override it.
      Remember that LBFGS only minimizes, so lower is better.
   **/
   public double objectiveFunction(double[] x) throws Exception {
        return (2*x[0]*x[0] + 3*x[1] + 1);
   }

   /**
      The gradient of the objective function, given variable assignments
      x.  This is specific to your problem, so you must override it.
   **/
   public double[] evaluateGradient(double[] x) throws Exception {
        double[] result = new double[x.length];
        result[0] = 4 * x[0];
        result[1] = 3;
        return result;
   }

使用此目标函数和梯度的实现运行代码会出现以下异常:

Exception in thread "main" Line search failed. See documentation of routine mcsrch. 
Error return of line search: info = 3 Possible causes: 
function or gradient are incorrect, or incorrect tolerances. (iflag == -1)

我没有更改默认值的公差。我做错了什么?

【问题讨论】:

    标签: machine-learning svm mathematical-optimization libsvm gradient-descent


    【解决方案1】:

    我认为您的成本函数没有最小值,因为x2 可以达到-Inf,而梯度算法找不到它。

    它是 x1 的二次函数,但不是 x2。我怀疑抛出异常是因为梯度算法找不到最优解,它“认为”问题是没有正确设置容差系数,或者梯度函数错误

    你的意思是 f(x) = 2*(x^2) + 3*x + 1 在你的对象函数中吗?

    【讨论】:

    • 可以,因为这是一个正则二次函数,二次函数总是有全局最优的。
    • 它是 x1 的二次函数,但不是 x2。我怀疑抛出异常是因为梯度算法找不到最优解,它“认为”问题是没有正确设置容差系数,或者梯度函数错误
    猜你喜欢
    • 2017-07-14
    • 2015-02-19
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    • 1970-01-01
    • 2015-04-18
    • 2013-09-29
    • 2017-02-06
    相关资源
    最近更新 更多