/3rd_party_code/minFunc/lbfgsUpdate.m
http://github.com/Sohl-Dickstein/Minimum-Probability-Flow-Learning · Objective C · 21 lines · 20 code · 1 blank · 0 comment · 3 complexity · 71f62353ce9ae32bb70f752844f9d0d3 MD5 · raw file
- function [old_dirs,old_stps,Hdiag] = lbfgsUpdate(y,s,corrections,debug,old_dirs,old_stps,Hdiag)
- ys = y'*s;
- if ys > 1e-10
- numCorrections = size(old_dirs,2);
- if numCorrections < corrections
- % Full Update
- old_dirs(:,numCorrections+1) = s;
- old_stps(:,numCorrections+1) = y;
- else
- % Limited-Memory Update
- old_dirs = [old_dirs(:,2:corrections) s];
- old_stps = [old_stps(:,2:corrections) y];
- end
-
- % Update scale of initial Hessian approximation
- Hdiag = ys/(y'*y);
- else
- if debug
- fprintf('Skipping Update\n');
- end
- end