machine-learning - RISO 的 L-BFGS 不起作用

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

我正在测试 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)

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

最佳答案

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

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

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

关于machine-learning - RISO 的 L-BFGS 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21019991/

相关文章:

Python:如何处理回归 Q-Q 图中的异常值?

r - 无法在 R 中训练 KSVM

c++ - 训练自定义 SVM 以在 OpenCV 中与 HOGDescriptor 一起使用

algorithm - 向量化帕累托前沿算法

machine-learning - 如何获得 `skbio` PCoA(主坐标分析)结果?

artificial-intelligence - 用于前馈神经网络训练的有效数据集大小

python-3.x - 如何根据 Keras 中的输出概率区分其为 True 或 False?

c - matlab 与 C 版本中的 svmtrain 函数执行时间

java - 哪个 Java 包包含高等数学函数?

algorithm - 尽量减少在指定路径上行驶时花费的时间