-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.xml
307 lines (262 loc) · 15.7 KB
/
index.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Runner</title>
<link>/</link>
<description>Recent content on Runner</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-gb</language>
<lastBuildDate>Mon, 04 Nov 2019 00:00:00 +0000</lastBuildDate>
<atom:link href="/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Jacobi's formula</title>
<link>/posts/2019-11-04-matrix-cookbook-46/</link>
<pubDate>Mon, 04 Nov 2019 00:00:00 +0000</pubDate>
<guid>/posts/2019-11-04-matrix-cookbook-46/</guid>
<description>\[\tag{46}\frac{\partial \det \left( \mathbf{Y} \right)}{\partial x}=\,\,\det \left( \mathbf{Y} \right) Tr\left[ \mathbf{Y}^{-1}\frac{\partial \mathbf{Y}}{\partial x} \right] \]Formula \((46)\) is actually Jacobi’s formula. 1
Analogy in functions
For a differentiable function \(f: D\subseteq R\rightarrow R\), for all \(x\) in some neighborhood of \(a\), \(f\) can be written as: 2\[f(x)=f(a)+f^{\prime}(a) (x−a)+R(x−a) \]and, \(L(x)=f(a)+f^{\prime}(a)(x−a)\) is the best affine approximation of the function \(f\) at \(a\).
or, the idea could be expressed in other way:\[f(x+\epsilon)=f(x)+f^{\prime}(x) \epsilon +R\epsilon \]</description>
</item>
<item>
<title>Derivative of log of determinant</title>
<link>/posts/2019-10-30-matrix-cookbook-43/</link>
<pubDate>Wed, 30 Oct 2019 00:00:00 +0000</pubDate>
<guid>/posts/2019-10-30-matrix-cookbook-43/</guid>
<description>\[\begin{equation}\tag{43}\partial(\ln (\operatorname{det}(\mathbf{X})))=\operatorname{Tr}\left(\mathbf{X}^{-1} \partial \mathbf{X}\right)\end{equation}\]
Lemma 1
\[\begin{equation}\sum_{i} \sum_{j} \mathbf{A}^{\mathrm{T}}_{i j} \mathbf{B}_{i j} = \operatorname{Tr}\left(\mathbf{A} \mathbf{B}\right)\end{equation}\]
Lemma 2 1
(Credit to https://statisticaloddsandends.wordpress.com/2018/05/24/derivative-of-log-det-x/)
\[\begin{equation}\frac{\partial(\operatorname{det} \mathbf{X})}{\partial \mathbf{X}_{i j}}=\mathbf{C}_{i j}\end{equation}\]
For a matrix \(X\), we define some terms:
The \((i,j)\) minor of \(X\), denoted \(M_{ij}\), is the determinant of the \((n-1) \times (n-1)\) matrix that remains after removing the \(i\)th row and \(j\)th column from \(X\).</description>
</item>
<item>
<title>Derivative of inverse matrix</title>
<link>/posts/2019-10-24-matrix-derivative/</link>
<pubDate>Thu, 24 Oct 2019 00:00:00 +0000</pubDate>
<guid>/posts/2019-10-24-matrix-derivative/</guid>
<description>\[\begin{equation}\tag{40}\partial\left(\mathbf{X}^{-1}\right)=-\mathbf{X}^{-1}(\partial \mathbf{X}) \mathbf{X}^{-1}\end{equation}\]
Explanation: 1
\[\begin{equation}\underbrace{(I)^{\prime}}_{=0}=\left(\mathbf{X} \mathbf{X}^{-1}\right)^{\prime}=\mathbf{X}^{\prime} \mathbf{X}^{-1}+\mathbf{X}\left(\mathbf{X}^{-1}\right)^{\prime} \Rightarrow\end{equation}\]
\[\begin{equation}\mathbf{X}\left(\mathbf{X}^{-1}\right)^{\prime}=-\mathbf{X}^{\prime} \mathbf{X}^{-1} \quad \Rightarrow\end{equation}\]
\[\begin{equation}\left(\mathbf{X}^{-1}\right)^{\prime}=-\mathbf{X}^{-1} \mathbf{X}^{\prime} \mathbf{X}^{-1}\end{equation}\]
\[\begin{equation}\tag{41}\partial(\operatorname{det}(\mathbf{X}))=\operatorname{Tr}(\operatorname{adj}(\mathbf{X}) \partial \mathbf{X})\end{equation}\]
BackgroundAdjugate MatrixThe adjugate of \(A\) is the transpose of the cofactor matrix \(C\) of \(X\),\[\begin{equation}\operatorname{adj}(\mathbf{X})=\mathbf{C}^{\top}\end{equation}\]
and,\[\begin{equation}\mathbf{X}^{-1}=\operatorname{det}(\mathbf{X})^{-1} \operatorname{adj}(\mathbf{X}) \quad \Rightarrow\end{equation}\]
\[\begin{equation}\operatorname{det}(\mathbf{X}) \mathbf{I} = \operatorname{adj}(\mathbf{X}) \mathbf{X}\end{equation}\]
Characteristic PolynomialThe characteristic polynomial of a square matrix is a polynomial which is invariant under matrix similarity and has the eigenvalues as roots.</description>
</item>
<item>
<title>Matrix cookbook - determinant</title>
<link>/posts/2019-10-17-matrix-cookbook-1.2-determinant/</link>
<pubDate>Fri, 11 Oct 2019 00:00:00 +0000</pubDate>
<guid>/posts/2019-10-17-matrix-cookbook-1.2-determinant/</guid>
<description>\[\begin{equation}\tag{18}\operatorname{det}(\mathbf{A})=\prod_{i} \lambda_{i} \quad \lambda_{i}=\operatorname{eig}(\mathbf{A})\end{equation}\]
\[\begin{equation}\tag{19}\operatorname{det}(c \mathbf{A})=c^{n} \operatorname{det}(\mathbf{A}), \quad \text { if } \mathbf{A} \in \mathbb{R}^{n \times n}\end{equation}\]
\[\begin{equation}\tag{20}\operatorname{det}\left(\mathbf{A}^{T}\right)=\operatorname{det}(\mathbf{A})\end{equation}\]
\[\begin{equation}\tag{21}\operatorname{det}(\mathbf{A B})=\operatorname{det}(\mathbf{A}) \operatorname{det}(\mathbf{B})\end{equation}\]
The determinant of a tranformation matrix is the scale of area/volume of the shape before and after the tranformation. \(\mathbf{A B}\) are two consecutive transformations, therefore its determinant is the product of two scales.
\[\begin{equation}\tag{22}\operatorname{det}\left(\mathbf{A}^{-1}\right)=1 / \operatorname{det}(\mathbf{A})\end{equation}\]</description>
</item>
<item>
<title>Matrix cookbook - Trace</title>
<link>/posts/2019-10-11-matrix-cookbook-trace/</link>
<pubDate>Fri, 11 Oct 2019 00:00:00 +0000</pubDate>
<guid>/posts/2019-10-11-matrix-cookbook-trace/</guid>
<description>\[\begin{equation}\tag{11}\operatorname{Tr}(\mathbf{A})=\sum_{i} A_{i i}\end{equation}\]
Let’s write the trace in a more convenient way. We have: 1\[\begin{equation}A e_{i}=\left[\begin{array}{ccc}{a_{11}} &amp; {\cdots} &amp; {a_{1 n}} \\ {\vdots} &amp; {\ddots} &amp; {\vdots} \\ {a_{n 1}} &amp; {\cdots} &amp; {a_{n n}}\end{array}\right]\left[\begin{array}{c}{0} \\ {\vdots} \\ {1} \\ {\vdots} \\ {0}\end{array}\right]=\left[\begin{array}{c}{a_{i 1}} \\ {\vdots} \\ {a_{i n}}\end{array}\right]\end{equation}\]where the \(1\) is in the \(i\)-th entry. This way:\[\begin{equation}\left\langle e_{i}, A e_{i}\right\rangle= e_{i}^{t} A e_{i}=A_{i i}\end{equation}\]So \(\operatorname{Tr}(\mathbf{A})=\sum_{i}A_{ii}\).</description>
</item>
<item>
<title>Matrix cookbook - Basics</title>
<link>/posts/2019-10-10-matrix-cookbook/</link>
<pubDate>Thu, 10 Oct 2019 00:00:00 +0000</pubDate>
<guid>/posts/2019-10-10-matrix-cookbook/</guid>
<description>\[\begin{equation}\tag{1}(\mathbf{A B})^{-1}=\mathbf{B}^{-1} \mathbf{A}^{-1}\end{equation}\]
\[\begin{equation}\tag{2}(\mathbf{A B C} \ldots)^{-1}=\ldots \mathbf{C}^{-1} \mathbf{B}^{-1} \mathbf{A}^{-1}\end{equation}\]
\[\begin{equation}\tag{3}\left(\mathbf{A}^{T}\right)^{-1}=\left(\mathbf{A}^{-1}\right)^{T}\end{equation}\]
\[\begin{equation}\tag{4}(\mathbf{A}+\mathbf{B})^{T}=\mathbf{A}^{T}+\mathbf{B}^{T}\end{equation}\]
\[\begin{equation}\tag{5}(\mathbf{A B})^{T}=\mathbf{B}^{T} \mathbf{A}^{T}\end{equation}\]
\[\begin{equation}\tag{6}(\mathbf{A B C} \ldots)^{T}=\ldots \mathbf{C}^{T} \mathbf{B}^{T} \mathbf{A}^{T}\end{equation}\]</description>
</item>
<item>
<title>The Element of Statistic Learning - Chapter 5</title>
<link>/posts/2019-10-07-esl-note/</link>
<pubDate>Mon, 07 Oct 2019 00:00:00 +0000</pubDate>
<guid>/posts/2019-10-07-esl-note/</guid>
<description>NotesEigen-decomposition\[S = \sum_{k=1}^N \rho_ku_ku_k^T\]</description>
</item>
<item>
<title>About me</title>
<link>/about/</link>
<pubDate>Wed, 20 Dec 2017 00:00:00 +0000</pubDate>
<guid>/about/</guid>
<description>This is my blog for self learning.</description>
</item>
<item>
<title>Exercise 4 - Neural Network Learning</title>
<link>/posts/2016-11-07-exercise4-neural-network-learning/</link>
<pubDate>Mon, 07 Nov 2016 00:00:00 +0000</pubDate>
<guid>/posts/2016-11-07-exercise4-neural-network-learning/</guid>
<description>1. Neural Networks Feedforward and const function The cost function for the neural network (without regularization) is
\[ J(\theta) = \frac{1}{m}\sum_{i=1}^m\sum_{k=1}^K \bigg[ −y_k^{(i)}\log((h_{θ}(x^{(i)}))_k)−(1−y_k^{(i)})\log(1−(h_θ(x^{(i)}))_k) \bigg] \],
where \(h_{\theta}(x^{(i)})\) is computed as shown in the Figure 2 and \(K = 10\) is the total number of possible labels. Note that \(h_θ(x^{(i)})_k = a^{(3)}_k\) is the activation (output value) of the \(k\)-th output unit.
Implementation-nnCostFunction.m
a1 = [ones(m, 1) X]; z2 = a1*Theta1&#39;; a2 = [ones(size(z2, 1), 1) sigmoid(z2)]; z3 = a2*Theta2&#39;; a3 = sigmoid(z3); yd = eye(num_labels); y = yd(y,:); log_dif = -log(a3).</description>
</item>
<item>
<title>Octave in Sublime Text3</title>
<link>/posts/2016-11-06-octave/</link>
<pubDate>Sun, 06 Nov 2016 00:00:00 +0000</pubDate>
<guid>/posts/2016-11-06-octave/</guid>
<description> Install Octave Download Octave from https://ftp.gnu.org/gnu/octave/windows/, and register its folder to environment variable Path.
Create build system for Octave file in Sublime Text3 Octave.sublime_build
{ &quot;cmd&quot;: [&quot;octave-gui&quot;, &quot;$file&quot;], &quot;shell&quot;: true // to show plots } Create short-cut for canceling build Add the line to Preferencesbindings
{ &quot;keys&quot;: [&quot;ctrl+shift+b&quot;], &quot;command&quot;: &quot;exec&quot;, &quot;args&quot;: {&quot;kill&quot;: true} }, </description>
</item>
<item>
<title>Exercise 3 - Multi-class Classification</title>
<link>/posts/2016-10-23-exercise3-multi-class-classification/</link>
<pubDate>Sun, 23 Oct 2016 00:00:00 +0000</pubDate>
<guid>/posts/2016-10-23-exercise3-multi-class-classification/</guid>
<description>Cost function, gradient of regularized logistic regression for multi-class classification are similar to exercise 2.
This exercise implement one-vs-all classification by training multiple regularized logistic regression classifiers, one for each of the K classes in our dataset.
oneVsAll.m
function [all_theta] = oneVsAll(X, y, num_labels, lambda) %ONEVSALL trains multiple logistic regression classifiers and returns all %the classifiers in a matrix all_theta, where the i-th row of all_theta %corresponds to the classifier for label i % [all_theta] = ONEVSALL(X, y, num_labels, lambda) trains num_labels % logisitc regression classifiers and returns each of these classifiers % in a matrix all_theta, where the i-th row of all_theta corresponds % to the classifier for label i % Some useful variables m = size(X, 1); n = size(X, 2); % You need to return the following variables correctly all_theta = zeros(num_labels, n + 1); % Add ones to the X data matrix X = [ones(m, 1) X]; % ====================== YOUR CODE HERE ====================== % Instructions: You should complete the following code to train num_labels % logistic regression classifiers with regularization % parameter lambda.</description>
</item>
<item>
<title>Exercise 3 - Neural Networks</title>
<link>/posts/2016-10-23-exercise3-neural-networks/</link>
<pubDate>Sun, 23 Oct 2016 00:00:00 +0000</pubDate>
<guid>/posts/2016-10-23-exercise3-neural-networks/</guid>
<description> Logistic regression cannot form more complex hypotheses as it is only a linear classifier1.
You could add more features (such as polynomial features) to logistic regression, but that can be very expensive to train.↩
</description>
</item>
<item>
<title>Exercise 2 - Logistic Regression (1)</title>
<link>/posts/2016-10-19-exercise2-logistic-regression/</link>
<pubDate>Wed, 19 Oct 2016 00:00:00 +0000</pubDate>
<guid>/posts/2016-10-19-exercise2-logistic-regression/</guid>
<description>1 Logistic Regression 1.1 Visualizing data plotdata.m function plotData(X, y) %PLOTDATA Plots the data points X and y into a new figure % PLOTDATA(x,y) plots the data points with + for the positive examples % and o for the negative examples. X is assumed to be a Mx2 matrix. % Create New Figure figure; hold on; % ====================== YOUR CODE HERE ====================== % Instructions: Plot the positive and negative examples on a % 2D plot, using the option &#39;k+&#39; for the positive % examples and &#39;ko&#39; for the negative examples.</description>
</item>
<item>
<title>Exercise 2 - Logistic Regression (2)</title>
<link>/posts/2016-10-21-exercise2-regularized-logistic-regression/</link>
<pubDate>Wed, 19 Oct 2016 00:00:00 +0000</pubDate>
<guid>/posts/2016-10-21-exercise2-regularized-logistic-regression/</guid>
<description>2 Regularized Logistic Regression 2.1 Visualizing the data {: .image-center} Figure shows that our dataset cannot be separated into positive and negative examples by a straight-line through the plot. Therefore, a straightforward application of logistic regression will not perform well on this dataset since logistic regression will only be able to find a linear decision boundary.
2.2 Feature mapping One way to fit the data better is to create more features from each data point.</description>
</item>
<item>
<title>Exercise 1- Linear Regression</title>
<link>/posts/2016-10-17-exercise1-linear-regression/</link>
<pubDate>Mon, 17 Oct 2016 00:00:00 +0000</pubDate>
<guid>/posts/2016-10-17-exercise1-linear-regression/</guid>
<description>1. Sublime Text3 Octave build system { &quot;cmd&quot;: [&quot;octave-gui&quot;, &quot;$file&quot;], &quot;shell&quot;: true // to show plots } 2. Linear regression with one variable plotdata.m function plotData(x, y) %PLOTDATA Plots the data points x and y into a new figure % PLOTDATA(x,y) plots the data points and gives the figure axes labels of % population and profit. % ====================== YOUR CODE HERE ====================== % Instructions: Plot the training data into a figure using the % &quot;figure&quot; and &quot;plot&quot; commands.</description>
</item>
<item>
<title>R markdown in Sublime Text3</title>
<link>/posts/2016-08-10-r-markdown/</link>
<pubDate>Thu, 11 Aug 2016 00:00:00 +0000</pubDate>
<guid>/posts/2016-08-10-r-markdown/</guid>
<description>1. Install Sublime Text plugin randy3k/R-box 2 Windows 2.1. Create my own sublime-build for R markdown files The default build system of R-box doesn’t work, and get the error
Error: &#39;\G&#39; is an unrecognized escape in character string starting &quot;&#39;C:\G&quot; Execution halted [Finished in 0.4s with exit code 1] since the windows path escape is not correctly handled.
This issue can be resolved by regular expression replacement 1</description>
</item>
<item>
<title>First Post</title>
<link>/posts/2016-07-30-first-post/</link>
<pubDate>Sat, 30 Jul 2016 00:00:00 +0000</pubDate>
<guid>/posts/2016-07-30-first-post/</guid>
<description>Below is just about everything you’ll need to style in the theme. Check the source code to see the many embedded elements within paragraphs.
Mathjax 1 LaTeX math delimiters: \\(a^2 + b^2 = c^2\\) or “\(a^2 + b^2 = c^2\)” for inline math \(a^2 + b^2 = c^2\); and \\[a^2 + b^2 = c^2\\] for displayed equations \[a^2 + b^2 = c^2\].
Heading 1 Heading 2 Heading 3 Heading 4 Heading 5 Heading 6 Body text Lorem ipsum dolor sit amet, test link adipiscing elit.</description>
</item>
</channel>
</rss>