diff --git a/homework_04_logistic_regression/homework/README.md b/homework_04_logistic_regression/homework/README.md index 271a005..bbe04d0 100644 --- a/homework_04_logistic_regression/homework/README.md +++ b/homework_04_logistic_regression/homework/README.md @@ -22,11 +22,11 @@ g(z_i)=g(\theta_i^T \mathbf{x})=\frac{e^{\theta_i^T\mathbf{x}}}{\sum\limits_{j=1 $$ 构造似然函数,若有$m$个训练样本: $$ -\begin{align} -L(\Theta)&=p(\mathbf{y}|\mathbf{X};\Theta) \\ -& = \prod\limits_{i=1}^{m} p(y^{i}|\mathbf{x}^{i};\Theta) \\ +\begin{aligned} +L(\Theta)&=p(\mathbf{y}|\mathbf{X};\Theta) \\\\ +& = \prod\limits_{i=1}^{m} p(y^{i}|\mathbf{x}^{i};\Theta) \\\\ & = \prod_{i=1}^m h_{\theta_i}(\mathbf{x}) -\end{align} +\end{aligned} $$ 对似然函数取对数,转换为: $$ @@ -35,21 +35,21 @@ $$ 对$log(h_{\theta_i}(\mathbf{x}))$求导得到: $$ \frac{\partial{log(h_{\theta_i}(\mathbf{x}))}}{\partial{z_k}}=\begin{cases} -1-h_{\theta_k}(\mathbf{x}) & \text{ if } k=i \\ +1-h_{\theta_k}(\mathbf{x}) & \text{ if } k=i \\\\ -h_{\theta_k}(\mathbf{x}) & else \end{cases} $$ 转换后的似然函数对$\theta$求偏导,在这里我们以只有一个训练样本的情况为例: $$ -\begin{align} -\frac{\partial}{\partial\theta_k}l(\Theta)&=\frac{\partial l(\Theta)}{\partial{z_k}}\cdot \frac{\partial z_k}{\partial \theta_k} \\ +\begin{aligned} +\frac{\partial}{\partial\theta_k}l(\Theta)&=\frac{\partial l(\Theta)}{\partial{z_k}}\cdot \frac{\partial z_k}{\partial \theta_k} \\\\ &=(y_k-h_{\theta_k}(\mathbf{x}))\mathbf{x} -\end{align} +\end{aligned} $$ 上式中$y_k$的表达式如下: $$ y_k=\begin{cases} -1 & \text{ if } k=i \\ +1 & \text{ if } k=i \\\\ 0 & else \end{cases} $$