Machine learning RISO的L-BFGS不工作

Machine learning RISO的L-BFGS不工作,machine-learning,svm,mathematical-optimization,libsvm,gradient-descent,Machine Learning,Svm,Mathematical Optimization,Libsvm,Gradient Descent,我正在测试RISO的L-BFGS库在Java中用于逻辑回归函数最小化的实现。是指向我正在使用的类的链接 为了测试库,我尝试最小化函数: 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 over

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

为了测试库,我尝试最小化函数:

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)

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

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

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


你的意思是目标函数中的
f(x)=2*(x^2)+3*x+1

可以,因为这是一个正则二次函数,二次函数总是具有全局最优解。它是x1的二次函数,但不是x2的二次函数。我怀疑这个异常被抛出是因为梯度算法无法找到最优解,它“认为”问题在于公差系数设置不正确,或者梯度函数错误