我尝试使用EJML wiki中的示例,其中我们使用了Levenberg Marquardt优化source code here
我将它与这个.Net version进行比较,在这个have中,我们可以给出函数模型参数。
例如:a*x^2+b*x+c,我们可以给出模型的所有参数作为输入。
但是,对于EJML LM代码,我看不到在哪里可以给出这些模型参数。
我将如何使用LM EJML类粘贴到下面:
public class Main {
public static void main(String[] args) {
LevenbergMarquardt lm = new LevenbergMarquardt(new LevenbergMarquardt.Function() {
@Override
public void compute(DenseMatrix64F param, DenseMatrix64F x, DenseMatrix64F y) {
// TODO Auto-generated method stub
System.out.println("param:");
param.print();
System.out.println("X:");
x.print();
//y=a*x^2+b*x+c
for (int i = 0; i < x.numRows; i++) {
double xx = x.get(i, 0);
y.set(i, 0, param.get(0, 0) * xx * xx +
param.get(1, 0) * xx + param.get(2, 0));
}
System.out.println("Y:");
y.print();
}
});
//Seed inital parameters
lm.optimize(new DenseMatrix64F(new double[][]{{1}, {1}, {1}}),
new DenseMatrix64F(new double[][]{{0.1975}, {0.5084}, {0.7353}, {0.9706},
{1.1891}}), new DenseMatrix64F(new double[][]{{-0.0126}, {0.2311},
{0.4412}, {1.0210}, {1.1891}}));
}
}那么我该如何给出这些模型参数呢?
发布于 2017-01-09 13:11:15
您可能想要检查DDogleg。它包含一个更强大的LM求解器,并在幕后使用EJML。您在EJML网站上找到的LM求解器旨在作为如何使用EJML的示例,并跳过一些细节。
https://stackoverflow.com/questions/36151890
复制相似问题