拟牛顿法(DFP、BFGS)在回归分析中的应用
来源:互联网 发布:淘宝大学哪个老师最好 编辑:程序博客网 时间:2024/05/16 08:15
现在来讲拟牛顿法,主要讲两种主要的拟牛顿法,第一种拟牛顿法是由Davidon提出来的,后经Fletcher和Powell修改整理的,所以称为DPF方法。第二种著名的拟牛顿法是由Broyden,Fletcher,Glodfard,Shanno四人独立提出来的,所以常被称为BFGS方法。下面给出拟牛顿法的算法框架。
下面给出实验结果
Quasi_newton.m
x = load('ex3x.dat'); y = load('ex3y.dat'); trustRegionBound = 1000; x = [ones(size(x,1),1) x]; meanx = mean(x);%求均值 sigmax = std(x);%求标准偏差 x(:,2) = (x(:,2)-meanx(2))./sigmax(2); x(:,3) = (x(:,3)-meanx(3))./sigmax(3); itera_num = 1000; %尝试的迭代次数 sample_num = size(x,1); %训练样本的次数 jj=0.00001; figure alpha = [0.1];%因为差不多是选取每个3倍的学习率来测试,所以直接枚举出来 plotstyle = {'b-'}; theta_grad_descent = zeros(size(x(1,:))); theta_old = zeros(size(x,2),1); %theta的初始值赋值为0 Jtheta = zeros(itera_num, 1);Jtheta(1) = (1/(2*sample_num)).*(x*theta_old-y)'*(x*theta_old-y); grad1 = (1/sample_num).*x'*(x*theta_old-y);Q=x'*x;a=(grad1'*grad1)/(grad1'*Q*grad1);H=inv(Q);d1=-(H*grad1);theta_new=theta_old+a*d1;for i = 2:itera_num %计算出某个学习速率alpha下迭代itera_num次数后的参数 Jtheta(i) = (1/(2*sample_num)).*(x*theta_new-y)'*(x*theta_new-y);%Jtheta是个行向量 grad_old=(1/sample_num).*x'*(x*theta_old-y); grad_new = (1/sample_num).*x'*(x*theta_new-y); L=grad_new-grad_old; s=theta_new-theta_old; H=H-(H'*L*L'*H)/(L'*H*L)+(s*s')/(s'*L); d=-H*grad_new; a=(grad_new'*grad_new)/(grad_new'*Q*grad_new); theta_old=theta_new; theta_new = theta_new + a*d; end K(1)=Jtheta(500) ; plot(0:99, Jtheta(1:100),'k-','LineWidth', 4); hold on theta_old = zeros(size(x,2),1); %theta的初始值赋值为0 Jtheta = zeros(itera_num, 1);Jtheta(1) = (1/(2*sample_num)).*(x*theta_old-y)'*(x*theta_old-y); grad1 = (1/sample_num).*x'*(x*theta_old-y);Q=x'*x;a=(grad1'*grad1)/(grad1'*Q*grad1);H=inv(Q);d1=-(H*grad1);theta_new=theta_old+a*d1;for i = 2:itera_num %计算出某个学习速率alpha下迭代itera_num次数后的参数 Jtheta(i) = (1/(2*sample_num)).*(x*theta_new-y)'*(x*theta_new-y);%Jtheta是个行向量 grad_old=(1/sample_num).*x'*(x*theta_old-y); grad_new = (1/sample_num).*x'*(x*theta_new-y); L=grad_new-grad_old; s=theta_new-theta_old; H=H-(H*L*s'+s*L'*H)/(L'*s)+(1+(L'*H*L)/(s'*L))*(s*s')/(s'*L); d=-H*grad_new; a=(grad_new'*grad_new)/(grad_new'*Q*grad_new); theta_old=theta_new; theta_new = theta_new + a*d; end K(1)=Jtheta(500) ; plot(0:99, Jtheta(1:100),'r-','LineWidth', 2); hold on %% legend('quasi-Newton-DFP','quasi-Newton-BFGS'); xlabel('Number of iterations') ylabel('Cost function')
0 0
- 拟牛顿法(DFP、BFGS)在回归分析中的应用
- 拟牛顿法中的DFP算法和BFGS算法
- 牛顿法在回归分析中的应用
- 拟牛顿法、DFP算法及BFGS算法
- 牛顿法与拟牛顿法,DFP法,BFGS法,L-BFGS法
- 算法面试---最速下降法、牛顿法、拟牛顿法(DFP,BFGS)、共轭梯度法
- L-BFGS的原理及在回归分析中的应用
- 寻优方法总结:最速下降法,牛顿下降法,阻尼牛顿法,拟牛顿法DFP/BFGS
- 寻找最优参数解:最速下降法,牛顿下降法,阻尼牛顿法,拟牛顿法DFP/BFGS
- 寻找最优参数解:最速下降法,牛顿下降法,阻尼牛顿法,拟牛顿法DFP/BFGS
- 牛顿法,dfp,bfgs,l-blgs,owl-qn
- 统计学习方法--学习笔记----6.1.1 Logistic 回归 (拟牛顿法- DFP算法)
- bfgs拟牛顿法
- 梯度下降法和拟牛顿法(四):在Logistic回归中的应用
- 拟牛顿法/Quasi-Newton,DFP算法/Davidon-Fletcher-Powell,及BFGS算法/Broyden-Fletcher-Goldfarb-Shanno
- 拟牛顿法/Quasi-Newton,DFP算法/Davidon-Fletcher-Powell,及BFGS算法/Broyden-Fletcher-Goldfarb-Shanno
- 拟牛顿法/Quasi-Newton,DFP算法/Davidon-Fletcher-Powell,及BFGS算法/Broyden-Fletcher-Goldfarb-Shanno
- 拟牛顿法/Quasi-Newton,DFP算法/Davidon-Fletcher-Powell,及BFGS算法/Broyden-Fletcher-Goldfarb-Shanno
- 移动开发(IOS) – UIKit框架
- 网格控件的简单实用
- 黑马程序员—java基础学习--继承(extends)
- Codeforces 3A-Shortest path of the king(BFS打印路径)
- ID3
- 拟牛顿法(DFP、BFGS)在回归分析中的应用
- 结构体最后的长度为0或1数组的作用
- BCG菜单按钮的简单使用
- 停止线程
- 移动开发(IOS) – Objective-C-07-文件管理
- 用Java实现 生产者/消费者问题
- NHibernate Config
- mysql中IN和EXITS效率
- C#数字图像处理<三>