0
Java의 로지스틱 회귀에 대한 함수 최소화를 위해 RISO의 L-BFGS 라이브러리 구현을 테스트하고 있습니다. Here은 내가 사용하는 클래스에 대한 링크입니다.RISO의 L-BFGS가 작동하지 않습니다.
/**
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;
}
이 코드를 실행 : 라이브러리는 객관적이고 I는 다음과 같이 구현 된 그라데이션 기능을 필요로
f(x) = 2*(x1^2) + 4*x2 + 5
:
나는 기능을 최소화하기 위해 노력하고, 라이브러리를 테스트하려면 이 목적 함수 및 그래디언트 구현은 다음 예외를 제공합니다.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)
나는 공차를 기본값에서 바꾸지 않았다. 내가 도대체 뭘 잘못하고있는 겁니까?
이것은 정규 2 차 함수이고 2 차 함수는 항상 전역 최적을 가질 수 있습니다. –
x1에서는 2 차 함수이지만 x2에서는 2 차 함수입니다. 그라디언트 알고리즘이 최적의 솔루션을 찾을 수 없기 때문에 예외가 발생하고 용인 계수가 올바르게 설정되지 않았거나 그라디언트 함수가 잘못되었다고 생각됩니다. – lennon310