Skip to content

Commit 35bccd1

Browse files
committed
Upload CS229 homework 2
1 parent c94a820 commit 35bccd1

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"Suppose at $t$-step, $\\theta = \\theta^*$"
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"$$\n",
15+
"M = \\sum_i^m\\sum_{z^{(i)}} Q_i^*(z^{(i)}) \\log \\frac{p(x^{(i)}, z^{(i)}; \\theta)}{Q^*(z^{(i)})}\n",
16+
"$$"
17+
]
18+
},
19+
{
20+
"cell_type": "markdown",
21+
"metadata": {},
22+
"source": [
23+
"where\n",
24+
"\n",
25+
"$$\n",
26+
"Q_i^*(z^{(i)}) = p(z^{(i)} | x^{(i)}; \\theta^*) = \\frac{p(x^{(i)}, z^{(i)}; \\theta^*)}{p(x^{(i)}; \\theta^*)}\n",
27+
"$$\n",
28+
"\n",
29+
"for each $i$, following the E-step. Note $Q_i^*(z^{(i)})$ is a constant indepedent of $\\theta$."
30+
]
31+
},
32+
{
33+
"cell_type": "markdown",
34+
"metadata": {},
35+
"source": [
36+
"Take derivative of $M$ over $\\theta$\n",
37+
"\n",
38+
"\\begin{align*}\n",
39+
"\\nabla_{\\theta}{M} \n",
40+
"&= \\sum_i^m\\sum_{z^{(i)}} Q_i^*(z^{(i)}) \\frac{Q_i^*(z^{(i)})}{p(x^{(i)}, z^{(i)};\\theta)} \\frac{1}{Q_i^*(z^{(i)})} \\nabla_{\\theta}p(x^{(i)}, z^{(i)};\\theta) \\\\\n",
41+
"&= \\sum_i^m\\sum_{z^{(i)}} \\frac{p(x^{(i)}, z^{(i)}; \\theta^*)}{p(x^{(i)}; \\theta^*)} \\frac{\\nabla_{\\theta}p(x^{(i)}, z^{(i)};\\theta)}{p(x^{(i)}, z^{(i)};\\theta)} \\\\\n",
42+
"\\end{align*}"
43+
]
44+
},
45+
{
46+
"cell_type": "markdown",
47+
"metadata": {},
48+
"source": [
49+
"Since $\\theta$ has converged to $\\theta^*$, setting $\\theta = \\theta^*$ will make $\\nabla_{\\theta}M = 0$."
50+
]
51+
},
52+
{
53+
"cell_type": "markdown",
54+
"metadata": {},
55+
"source": [
56+
"\\begin{align*}\n",
57+
"\\nabla_{\\theta}{M}|_{\\theta = \\theta^*} \n",
58+
"&= \\sum_i^m\\sum_{z^{(i)}} \\frac{p(x^{(i)}, z^{(i)}; \\theta^*)}{p(x^{(i)}; \\theta^*)}\\frac{\\nabla_{\\theta}p(x^{(i)}, z^{(i)};\\theta)|_{\\theta = \\theta^*}}{p(x^{(i)}, z^{(i)};\\theta^*)} \\\\\n",
59+
"&= \\sum_i^m\\sum_{z^{(i)}} \\frac{\\nabla_{\\theta}p(x^{(i)}, z^{(i)};\\theta)|_{\\theta = \\theta^*}}{p(x^{(i)}; \\theta^*)} \\\\\n",
60+
"&= \\sum_i^m \\frac{\\nabla_{\\theta}p(x^{(i)}, \\theta)|_{\\theta = \\theta^*}}{p(x^{(i)}; \\theta^*)} \\\\\n",
61+
"&= \\sum_i^m \\nabla_{\\theta} \\log p(x^{(i)}; \\theta)|_{\\theta = \\theta^*} \\\\\n",
62+
"&= \\nabla_{\\theta} \\sum_i^m \\log p(x^{(i)}; \\theta)|_{\\theta = \\theta^*} \\\\\n",
63+
"&= \\nabla_{\\theta} \\ell(\\theta) \\\\\n",
64+
"&= 0\n",
65+
"\\end{align*}"
66+
]
67+
},
68+
{
69+
"cell_type": "markdown",
70+
"metadata": {},
71+
"source": [
72+
"Therefore, upon convergence, Letting $\\nabla_{\\theta}M = 0$ is equivalent to letting $\\nabla_{\\theta} \\ell = 0$."
73+
]
74+
}
75+
],
76+
"metadata": {
77+
"anaconda-cloud": {},
78+
"kernelspec": {
79+
"display_name": "Python [default]",
80+
"language": "python",
81+
"name": "python3"
82+
},
83+
"language_info": {
84+
"codemirror_mode": {
85+
"name": "ipython",
86+
"version": 3
87+
},
88+
"file_extension": ".py",
89+
"mimetype": "text/x-python",
90+
"name": "python",
91+
"nbconvert_exporter": "python",
92+
"pygments_lexer": "ipython3",
93+
"version": "3.5.3"
94+
}
95+
},
96+
"nbformat": 4,
97+
"nbformat_minor": 2
98+
}

0 commit comments

Comments
 (0)