How does Matlab build-in Quasi-Newton method calculate the gradient?
9 ビュー (過去 30 日間)
I use matlab build-in function 'fminunc' to run some optimization for my image registration problem. I set the options as:
options = optimset('LargeScale', 'off', 'Display', 'iter-detailed', 'TolX', 0.0001, 'TolFun', 0.001, 'GradObj', 'off', 'DerivativeCheck', 'off';
I think it then uses Quasi-Newton (L-BFGS) method to do the optimization.
When the 'GradObj' is 'off', then the 'fminunc' calculate the gradient of the parameters need to be optimzed for me. (I suppose the Matlab use finite difference method to get the gradient)
I also try to provide the gradient by myself using finite difference method as well, then I set 'GradObj' is 'on'.
However, I always got much better results when I use the Matlab's calculation (When 'GradObj' is 'off').
May I ask where can I find the codes the matlab build-in function calculating the gradient please? I wish to compare with my own implementation to find the mistakes I might make.
Thanks very much and have a nice day.
回答 (2 件)
Andy 2011 年 5 月 20 日
I don't have a direct answer for you, but you can dig into it a little bit further by typing
at the command line. It looks like some internal functions are called, not all of which are editable (perhaps some are MEX functions?). But you can see a couple of them:
Perhaps you can gain some insight from these functions, but it may just be the case that the algorithm is buried in a MEX function and TMW does not intend for users to be able to see it.