Check of the gradient of the negative log-likelihood

조회 수: 2 (최근 30일)
boureghda mohammed
boureghda mohammed 2017년 1월 14일
편집: Matt J 2017년 1월 16일
To verify the the supplied gradient of the negative log-likelihood calculated by using Gaussian filtering (differentiated Uuscented Kalman Filter) I used the DerivativeCheck from Matlab by:
Opt =optimset('DerivativeCheck','on','GradObj','on','Display','iter',,'Algorithm','sqp','FinDiffType','central');
problem = createOptimProblem('fmincon','objective',@neg_logLik,'x0',th0,'lb',LB,'ub',UB,'options',Opt);
I get the following message:
Objective function derivatives:
Maximum relative discrepancy between derivatives = 0.9
Caution: user-supplied and central finite-difference derivatives do
not match within 1e-006 relative tolerance.
To displaying full derivativecheck output, I used the following code:
To displaying full 'DerivativeCheck' output, I used the following code:
[x,fval,exitflag,output,lambda,grad]=fmincon(...)
From https://www.mathworks.com/matlabcentral/answers/46854-displaying-full-derivativecheck-output.
I did this with MaxIter = 0 and GradObj = 'off'. the output grad will be fmincon's idea of the gradient of −L(θ) calculated by finite difference at the initial point and I get the following results:
My supplied derivatives results:
-120.5610
42.5878
-28.1507
9.7675
and finite difference results:
-12.0561
4.2588
-2.8151
0.9767
My results and the results of the finite difference look the same but my results multiplied by 10. What's wrong?

답변 (1개)

Matt J
Matt J 2017년 1월 14일
편집: Matt J 2017년 1월 16일
My results and the results of the finite difference look the same but my results multiplied by 10. What's wrong?
Isn't it obvious? Your gradient computation is off by a factor of 10.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by