|
a |
|
b/combinedDeepLearningActiveContour/minFunc/lbfgsUpdate.m |
|
|
1 |
function [old_dirs,old_stps,Hdiag] = lbfgsUpdate(y,s,corrections,debug,old_dirs,old_stps,Hdiag) |
|
|
2 |
ys = y'*s; |
|
|
3 |
if ys > 1e-10 |
|
|
4 |
numCorrections = size(old_dirs,2); |
|
|
5 |
if numCorrections < corrections |
|
|
6 |
% Full Update |
|
|
7 |
old_dirs(:,numCorrections+1) = s; |
|
|
8 |
old_stps(:,numCorrections+1) = y; |
|
|
9 |
else |
|
|
10 |
% Limited-Memory Update |
|
|
11 |
old_dirs = [old_dirs(:,2:corrections) s]; |
|
|
12 |
old_stps = [old_stps(:,2:corrections) y]; |
|
|
13 |
end |
|
|
14 |
|
|
|
15 |
% Update scale of initial Hessian approximation |
|
|
16 |
Hdiag = ys/(y'*y); |
|
|
17 |
else |
|
|
18 |
if debug |
|
|
19 |
fprintf('Skipping Update\n'); |
|
|
20 |
end |
|
|
21 |
end |