[吴恩达机器学习]Lecture2个人笔记
·
tags:
- 机器学习
- 笔记
2-1 模型描述
mmm:训练集样本数
xxx:输入
yyy:输出
hθ(x)=θ0+θ1xh_\theta(x) = \theta_0 + \theta_1 xhθ(x)=θ0+θ1x:Hypothesis
2-2 代价函数
The cost function
在 linear regression 中,修改 θ0、θ1\theta_0、\theta_1θ0、θ1 使 h(x)h(x)h(x) 更好的拟合数据
- 关于 θ0、θ1\theta_0、\theta_1θ0、θ1 对函数 J(θ0,θ1)J(\theta_0,\theta_1)J(θ0,θ1) 求最小值
平方误差函数:解决回归问题最常用手段
如果直接把误差相加会正负相互抵消,所以需要把误差平方
- Cost function
J(θ0,θ1)=12m∑i=1m(hθ(x(i))−y(i))2 J(\theta_0,\theta_1) = \frac{1}{2m} \sum_{i=1}^{m}(h_\theta(x^{(i)})-y^{(i)})^2 J(θ0,θ1)=2m1i=1∑m(hθ(x(i))−y(i))2 - Goal
minθ0,θ1 J(θ0,θ1)⏟cost function \underset{\theta_0,\theta_1}{\text{min}} \ \underbrace{J(\theta_0,\theta_1)}_{cost \ function} θ0,θ1min cost functionJ(θ0,θ1)
2-3 梯度下降
Gradient descent algorithm
repeat until convergence θj:=θj−α∂∂θjJ(θ0,θ1)\theta_j := \theta_j - \alpha \frac{\partial}{\partial \theta_j} J(\theta_0,\theta_1)θj:=θj−α∂θj∂J(θ0,θ1)
α\alphaα:learning rate
- α\alphaα 过大可能无法收敛
Simultaneous update θ0\theta_0θ0 and θ1\theta_1θ1
靠近局部最低点,slope 减小,移动的幅度会自动变得越来越小
- So, no need to decrease α\alphaα over time
“Batch” Gradient Descent
- “Batch”: Each step of gradient descent uses all the training examples
更多推荐
所有评论(0)