资源简介
SAE工具箱,可用于神经网络和深度网络,提供各种参数优化的方法。
代码片段和文件信息
function [tx_newf_newg_newfunEvalsH] = ArmijoBacktrack(...
xtdffrggtdc1LStolXdebugdoPlotsaveHessianCompfunObjvarargin)
%
% Backtracking linesearch to satisfy Armijo condition
%
% Inputs:
% x: starting location
% t: initial step size
% d: descent direction
% f: function value at starting location
% fr: reference function value (usually funObj(x))
% gtd: directional derivative at starting location
% c1: sufficient decrease parameter
% debug: display debugging information
% LS: type of interpolation
% tolX: minimum allowable step length
% doPlot: do a graphical display of interpolation
% funObj: objective function
% varargin: parameters of objective function
%
% Outputs:
% t: step length
% f_new: function value at x+t*d
% g_new: gradient value at x+t*d
% funEvals: number function evaluations performed by line search
% H: Hessian at initial guess (only computed if requested
% Evaluate the objective and Gradient at the Initial Step
if nargout == 6
[f_newg_newH] = feval(funObj x + t*d varargin{:});
else
[f_newg_new] = feval(funObj x + t*d varargin{:});
end
funEvals = 1;
while f_new > fr + c1*t*gtd || ~isLegal(f_new)
temp = t;
if LS == 0 || ~isLegal(f_new)
% Backtrack w/ fixed backtracking rate
if debug
fprintf(‘Fixed BT\n‘);
end
t = 0.5*t;
elseif LS == 2 && isLegal(g_new)
% Backtracking w/ cubic interpolation w/ derivative
if debug
fprintf(‘Grad-Cubic BT\n‘);
end
t = polyinterp([0 f gtd; t f_new g_new‘*d]doPlot);
elseif funEvals < 2 || ~isLegal(f_prev)
% Backtracking w/ quadratic interpolation (no derivative at new point)
if debug
fprintf(‘Quad BT\n‘);
end
t = polyinterp([0 f gtd; t f_new sqrt(-1)]doPlot);
else%if LS == 1
% Backtracking w/ cubic interpolation (no derivatives at new points)
if debug
fprintf(‘Cubic BT\n‘);
end
t = polyinterp([0 f gtd; t f_new sqrt(-1); t_prev f_prev sqrt(-1)]doPlot);
end
% Adjust if change in t is too small/large
if t < temp*1e-3
if debug
fprintf(‘Interpolated Value Too Small Adjusting\n‘);
end
t = temp*1e-3;
elseif t > temp*0.6
if debug
fprintf(‘Interpolated Value Too Large Adjusting\n‘);
end
t = temp*0.6;
end
f_prev = f_new;
t_prev = temp;
if ~saveHessianComp && nargout == 6
[f_newg_newH] = feval(funObj x + t*d varargin{:});
else
[f_newg_new] = feval(funObj x + t*d varargin{:});
end
funEvals = funEvals+1;
% Check whether step size has become too small
if sum(abs(t*d)) <= tolX
if debug
fprintf(‘Backtracking Line Search Failed\n‘);
end
t = 0;
f_new = f;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3251 2011-01-03 21:39 minFunc\ArmijoBacktrack.m
文件 807 2011-01-03 21:39 minFunc\autoGrad.m
文件 901 2011-01-03 21:39 minFunc\autoHess.m
文件 317 2011-01-03 21:39 minFunc\autoHv.m
文件 870 2011-01-03 21:39 minFunc\autoTensor.m
文件 385 2011-01-03 21:39 minFunc\callOutput.m
文件 1845 2011-01-03 21:39 minFunc\conjGrad.m
文件 995 2011-01-03 21:39 minFunc\dampedUpdate.m
文件 2421 2011-01-03 21:39 minFunc\example_minFunc.m
文件 1604 2011-01-03 21:39 minFunc\example_minFunc_LR.m
文件 107 2011-01-03 21:39 minFunc\isLegal.m
文件 924 2011-01-03 21:39 minFunc\lbfgs.m
文件 2408 2011-01-03 21:39 minFunc\lbfgsC.c
文件 7707 2011-01-03 21:39 minFunc\lbfgsC.mexa64
文件 7733 2011-01-03 21:39 minFunc\lbfgsC.mexglx
文件 9500 2011-01-03 21:39 minFunc\lbfgsC.mexmac
文件 12660 2011-01-03 21:39 minFunc\lbfgsC.mexmaci
文件 8800 2011-01-03 21:39 minFunc\lbfgsC.mexmaci64
文件 7168 2011-01-03 21:39 minFunc\lbfgsC.mexw32
文件 9728 2011-01-03 21:39 minFunc\lbfgsC.mexw64
文件 614 2011-01-03 21:39 minFunc\lbfgsUpdate.m
文件 417 2011-01-03 21:39 minFunc\logistic\LogisticDiagPrecond.m
文件 216 2011-01-03 21:39 minFunc\logistic\LogisticHv.m
文件 659 2011-01-03 21:39 minFunc\logistic\LogisticLoss.m
文件 1154 2011-01-03 21:39 minFunc\logistic\mexutil.c
文件 317 2011-01-03 21:39 minFunc\logistic\mexutil.h
文件 227 2011-01-03 21:39 minFunc\logistic\mylogsumexp.m
文件 3965 2011-01-03 21:39 minFunc\logistic\repmatC.c
文件 7680 2011-01-03 21:39 minFunc\logistic\repmatC.dll
文件 20682 2011-01-03 21:39 minFunc\logistic\repmatC.mexglx
............此处省略21个文件信息
评论
共有 条评论