【机器学习】-Week3 5. Simplified regre

2019-12-29  本文已影响0人  Kitty_风花

Simplified Cost Function and Gradient Descent

We can compress our cost function's two conditional cases into one case:

Notice that when y is equal to 1, then the second term (1-y)\log(1-h_\theta(x))(1−y)log(1−hθ​(x)) will be zero and will not affect the result. If y is equal to 0, then the first term -y \log(h_\theta(x))−ylog(hθ​(x)) will be zero and will not affect the result.

We can fully write out our entire cost function as follows:

A vectorized implementation is:

Gradient Descent

Remember that the general form of gradient descent is:

We can work out the derivative part using calculus to get:

Notice that this algorithm is identical to the one we used in linear regression. We still have to simultaneously update all values in theta.

A vectorized implementation is:

Note:  the gradient descent equation should have a 1/m factor]

Note:the gradient descent equation should have a 1/m factor

来源:coursera 斯坦福 吴恩达 机器学习

上一篇 下一篇

猜你喜欢

热点阅读