📔
liu_yu_bo_play_with_machine_learning
More
Search
Ctrl + K
9-3 逻辑回归算法损失函数的梯度
Previous
Chapter9
Next
Chapter9
Last updated
4 years ago
线性回归算法的梯度:
逻辑回归算法的梯度:
∇
J
(
θ
)
=
1
m
⋅
{
∑
i
=
1
m
(
y
^
(
i
)
−
y
(
i
)
)
∑
i
=
1
m
(
y
^
(
i
)
−
y
(
i
)
)
⋅
X
1
(
i
)
∑
i
=
1
m
(
y
^
(
i
)
−
y
(
i
)
)
⋅
X
2
(
i
)
.
.
.
∑
i
=
1
m
(
y
^
(
i
)
−
y
(
i
)
)
⋅
X
n
(
i
)
}
=
1
m
⋅
X
b
T
⋅
(
σ
(
X
b
θ
)
−
y
)
\nabla J(\theta) = \frac{1}{m} \cdot \ \begin{Bmatrix} \sum_{i=1}^m (\hat y^{(i)}-y^{(i)}) \\ \sum_{i=1}^m (\hat y^{(i)}-y^{(i)})\cdot X_1^{(i)} \\ \sum_{i=1}^m (\hat y^{(i)}-y^{(i)})\cdot X_2^{(i)} \\ ... \\ \sum_{i=1}^m (\hat y^{(i)}-y^{(i)})\cdot X_n^{(i)} \\ \end{Bmatrix} \ = \frac{1}{m}\cdot X_b^T\cdot (\sigma(X_b\theta)-y)
∇
J
(
θ
)
=
m
1
⋅
⎩
⎨
⎧
∑
i
=
1
m
(
y
^
(
i
)
−
y
(
i
)
)
∑
i
=
1
m
(
y
^
(
i
)
−
y
(
i
)
)
⋅
X
1
(
i
)
∑
i
=
1
m
(
y
^
(
i
)
−
y
(
i
)
)
⋅
X
2
(
i
)
...
∑
i
=
1
m
(
y
^
(
i
)
−
y
(
i
)
)
⋅
X
n
(
i
)
⎭
⎬
⎫
=
m
1
⋅
X
b
T
⋅
(
σ
(
X
b
θ
)
−
y
)