线性回归的梯度体面(吴安德鲁的机器学习第1周)

问题描述 投票:0回答:3

我正在尝试了解用于线性回归的梯度下降算法。

问题是为什么我们在theta1的末尾乘以x(1),而不在theta0的末尾乘以x(1)?

非常感谢!

enter image description here

machine-learning linear-regression linear-gradients gradient-descent calculus
3个回答
0
投票

假设是theta0 + theta1*x。在区分theta0theta1时,分别得到1x。因此,您会获得x的更新theta1,而不是theta0的更新。有关更多详细信息,请参阅本文档cs229-notes1


0
投票

简而言之,因为偏导数和链式规则的应用。

对于Theta 0,当采用损耗函数(MSE)相对于Theta 0的导数(或Beta 0 / Intercept)时,导数的形式为等式1最右边。

imagine...
Y = Mx + C
M = Theta 1
C = Theta 0

Loss Function = (Y - (Mx + C))^2

The derivative is in the form of f(x) * f'(x) if that makes sense. f'(x) in Theta 0 is 1 (watch the video to understand the derivate). So

2(Y - (Mx + C)) *  derivative of with respect to C of (Y - (Mx + C))
= 2(Y - (Mx + C)) [disregard the 2 in front]


For Theta 1, when you take derivative of the loss function (MSE) with respect to Theta 1 (Or Beta 1 / slope ), your derivative is in the form shown the rightmost of eq1. In this case f'(x) is x, because.....

2(Y - (Mx + C)) *  derivative of with respect to M of (Y - (Mx + C))
= 2(Y - (Mx + C)) * (1*x) [because the only term that is left is dx(Mx)]

以下是可以帮助您的视频https://www.youtube.com/watch?v=sDv4f4s2SB8


0
投票

线性回归的损失函数由]给出>

J = {(HthetaX(i))-y}^2

并且我们有渐变=损耗的导数。因此,

DJ/Dtheta = 2*(HthetaX(i))-y)*X(i)。现在theta0 X(i) ==1,因此

DJ/Dtheta for Theta0 = 2*(Htheta*X(i))-y)
© www.soinside.com 2019 - 2024. All rights reserved.