How to use fminunc providing gradient and hessian?

조회 수: 3 (최근 30일)
MRC
MRC 2014년 2월 2일
편집: Matt J 2014년 2월 2일
Hi, could you help me in making this code (attached) working? Thanks!

채택된 답변

Matt J
Matt J 2014년 2월 2일
You need to return the gradient and Hessian
function [val,g,H]=log_lik(theta,ix)
Also, these tolerances look unrealistically small
'TolX',10^-30,'TolFun',10^-30

추가 답변 (1개)

Paul
Paul 2014년 2월 2일
편집: Paul 2014년 2월 2일
What Matt said and the way you want to calculate the gradient and hessian is not gonna work. since val is just a single value, the function jacobian is not gonna work.
  댓글 수: 6
Paul
Paul 2014년 2월 2일
편집: Paul 2014년 2월 2일
Maybe you misunderstood me Matt. I meant what you said is right and that the way he was calculating the jacobian and hessian wasn't gonna work. Cris, jacobian works on symbolic expressions. You could try using fminunc without the gradient and hessian. Or else derive the gradient and hessian expressions yourself by hand or using matlab. These should depend on the values in theta.
Matt J
Matt J 2014년 2월 2일
편집: Matt J 2014년 2월 2일
@Paul: Ah! I get it now.
@Cris: If you are setting GradObj and Hessian to 'on' because of Walter's remark here, I think it's too soon. I think you should try with the default gradient and Hessian calculation first and then add your own once you're getting decent optimization results and you just need to make small improvements to speed and accuracy.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by