# 9-3 逻辑回归算法损失函数的梯度

![](http://windmissing.github.io/images/2019/162.jpg)

线性回归算法的梯度： ![](http://windmissing.github.io/images/2019/163.jpg) 逻辑回归算法的梯度：

$$
\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)
$$
