How to use fminunc providing gradient and hessian?

 Respuesta aceptada

Matt J
Matt J el 2 de Feb. de 2014
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

Más respuestas (1)

Paul
Paul el 2 de Feb. de 2014
Editada: Paul el 2 de Feb. de 2014

0 votos

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 comentarios

MRC
MRC el 2 de Feb. de 2014
In fact it does not work. What do you mean by single value?
Matt J
Matt J el 2 de Feb. de 2014
What Matt said...
It definitely isn't going to work if the function doesn't return g and H. Whether g and H are correctly computed is another matter, but it doesn't invalidate my advice.
Matt J
Matt J el 2 de Feb. de 2014
What do you mean by single value?
The jacobian function is from the Symbolic Math Toolbox. But you are doing non-symbolic math here.
MRC
MRC el 2 de Feb. de 2014
Are you suggesting that I cannot use the jacobian function inside fminunc? Or, how should I change my code in order to use it?
Paul
Paul el 2 de Feb. de 2014
Editada: Paul el 2 de Feb. de 2014
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 el 2 de Feb. de 2014
Editada: Matt J el 2 de Feb. de 2014
@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.

Iniciar sesión para comentar.

Preguntada:

MRC
el 2 de Feb. de 2014

Editada:

el 2 de Feb. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by