Skip to content

Commit

Permalink
Merge pull request fengdu78#11 from Chandlercjy/master
Browse files Browse the repository at this point in the history
fix formular typo
  • Loading branch information
fengdu78 authored May 7, 2018
2 parents 5232cf9 + 26e2762 commit 5a29f2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions markdown/week3.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ initialTheta=zeros(2,1);
参考视频: 7 - 2 - Cost Function (10 min).mkv

上面的回归问题中如果我们的模型是:
${h_\theta}\left( x \right)={\theta_{0}}+{\theta_{1}}{x_{1}}+{\theta_{2}}{x_{2}}+{\theta_{3}}{x_{3}}+{\theta_{4}}{x_{4}}$
${h_\theta}\left( x \right)={\theta_{0}}+{\theta_{1}}{x_{1}}+{\theta_{2}}{x_{2}^2}+{\theta_{3}}{x_{3}^3}+{\theta_{4}}{x_{4}^4}$
我们可以从之前的事例中看出,正是那些高次项导致了过拟合的产生,所以如果我们能让这些高次项的系数接近于0的话,我们就能很好的拟合了。
所以我们要做的就是在一定程度上减小这些参数$\theta $ 的值,这就是正则化的基本方法。我们决定要减少${\theta_{3}}$和${\theta_{4}}$的大小,我们要做的便是修改代价函数,在其中${\theta_{3}}$和${\theta_{4}}$ 设置一点惩罚。这样做的话,我们在尝试最小化代价时也需要将这个惩罚纳入考虑中,并最终导致选择较小一些的${\theta_{3}}$和${\theta_{4}}$。
修改后的代价函数如下:$\underset{\theta }{\mathop{\min }}\,\frac{1}{2m}[\sum\limits_{i=1}^{m}{{{\left( {{h}_{\theta }}\left( {{x}^{(i)}} \right)-{{y}^{(i)}} \right)}^{2}}+1000\theta _{3}^{2}+10000\theta _{4}^{2}]}$
Expand Down Expand Up @@ -490,7 +490,7 @@ ${h_\theta}\left( x \right)={\theta_{0}}+{\theta_{1}}{x_{1}}+{\theta_{2}}{x_{2}}

$J\left( \theta \right)=\frac{1}{2m}\sum\limits_{i=1}^{m}{[({{({h_\theta}({{x}^{(i)}})-{{y}^{(i)}})}^{2}}+\lambda \sum\limits_{j=1}^{n}{\theta _{j}^{2}})]}$

如果我们要使用梯度下降法令这个代价函数最小化,因为我们未对进行正则化,所以梯度下降算法将分两种情形:
如果我们要使用梯度下降法令这个代价函数最小化,因为我们未对$\theta_0$进行正则化,所以梯度下降算法将分两种情形:

$Repeat$ $until$ $convergence${

Expand Down

0 comments on commit 5a29f2e

Please sign in to comment.