function [localopt, fX, ii]=gradopt3(init,EGfn, maxit, P1, P2, P3, P4, P5, P6, P7) % function [localopt, fX, ii]=gradopt3(init,EGfn, maxit, P1, P2, P3, P4, P5, P6, P7) % % Minimizes an Energy function using Gradient function. EGfn should be a string % containing a function that returns energy and gradient as two args. Start at % X=init and use bold-driver-like algorithm to adjust parameters for a % gradient-based descent. Not sure if it's the same as a method with a name. It % seems different to quickprop, delta-bar-delta, ... % % Usage is compatible with Carl's minimize (which you should go use instead): % http://www.gatsby.ucl.ac.uk/~edward/code/minimize/ % or if you want a gradient only algorithm see Macopt: % http://www.inference.phy.cam.ac.uk/mackay/c/macopt.html % Also try L-BFGS-B wrapper from http://www.gatsby.ucl.ac.uk/~snelson/ % % Iain Murray October 2004, October 2005 maxit=abs(maxit); % compatibility with Carl's minimize % There's a better way to do callbacks, but grab Carl's code for now: argstr = [EGfn, '(Xprop']; for i = 1:(nargin - 3) argstr = [argstr, ',P', int2str(i)]; end argstr = [argstr, ')']; eta=0.1; epsilon=repmat(0.1,size(init)); X=init;Xprop=X; [E,G]=eval(argstr); it=0; fX=[]; ii=[]; while (sum(epsilon)>0)&&(it0).*epsilon*1.1+(G.*Gprop<0).*epsilon*0.5; epsilon=epsilon/sqrt(sum(epsilon.^2)); % Can't do this if can't evaluate function: if Eprop