ufldl学习笔记与编程作业:Linear Regression(线性回归)

接下来准备系统的学习一下deep learning课程,一方面是现在学校暑期课程刚好选到,另一方面也是掌握一个现在的热门技能。
UFLDL是斯坦福大学吴恩达(Andrew Ng)教授主编的深度学习资料《Unsupervised Feature Learning and Deep Learning》(2014年新版)的简称,今天学习的是第一课:Linear Regression。
线性回归概念很好理解,主要问题来自于编程作业:

Complete the following steps for this exercise: Fill in the linear_regression.m file to compute J(θ)J(θ) for the linear regression problem as defined earlier. Store the computed value in the variable. You may complete both of these steps by looping over the examples in the training set (the columns of the data matrix X) and, for each one, adding its contribution to f and g. We will create a faster version in the next exercise.
简单来说,这个实验里,你只需要按照公式给出代价函数f的代码和梯度函数g的代码,剩下的Function Minimization的过程已经由资料里的minfunc函数实现了。
从一个最简单的线性回归,可以很清晰地看出建模解决问题的一般思路。
1 定义目标函数;
2 最优化目标函数:求偏导数,求梯度。通过最优化的手段,比如梯度下降,拟牛顿发等。求出最优解。

  f=0;  
  g=zeros(size(theta));  
  h = theta' * X;  
  f = (1/2)*h*h';
  g = X*((h-y)');  
 h = theta' * X;  
 diff=h-y; 
 f=sum(diff.*diff)/2;
 g = X*((h-y)');%教程公式里已经给出求出梯度后的公式,这里直接使用即可。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值