--- tags: 機器學習技法 --- Ch13 Deep Learning === ## Content [TOC] ## [Slides & Videos](https://www.csie.ntu.edu.tw/~htlin/mooc/) ## [Deep Neural Network](https://www.coursera.org/learn/machine-learning-techniques/lecture/WF0GO/deep-neural-network) ### Physical Interpretation of NNet Revisited - 每個 layer 就是在從 data 當中 **extract pattern** ### Shallow versus Deep Neural Networks  ### Meaningfulness of Deep Learning  - 在 raw feature 只有非常有限的物理意義,但卻要做非常複雜的分類的時候 (例如一個一個 pixel),DL 會很有用 ### Challenges and Key Techiniques for Deep Learning  ### A Two-Step Deep Learning Framework  - 後面會講 ## [Autoencoder](https://www.coursera.org/learn/machine-learning-techniques/lecture/F4DBY/autoencoder) ### Information-Preserving Encoding - 我們希望 pre-train 出好的 weight - 但是不知道 pre-trained weight 之後會拿來做什麼,那就讓他保留所有資訊吧 ### Information-Preserving Neural Network - 做一個 $d$-$\tilde d$-$d$ NN - 讓 NN 去逼近 identity function 有什麼好處? ### Usefulness  ### Basic Autoencoder  - 有時候會限制 encode 跟 decode 的 weight 要一樣 - > Q: 這樣真的可以 decode 出原本的 x 嗎 @@ ### Pre-Training with Autoencoders  - 要 pre-train 第 $l-1$ 和第 $l$ 層之間的 weight,就把第 $l-1$ 層的輸出當成 input 來訓練 autoencoder。然後從第 0 層依序 pre-train 到最後一層 ## [Denoising Autoencoder](https://www.coursera.org/learn/machine-learning-techniques/lecture/qwWBz/denoising-autoencoder) ### Regularization in Deep Learning - high **model complexity**: regularization needed - structural decisions/**constraints** - weight decay or weight elimination **regularizers** - early stopping - next: another regularization technique ### Reasons of Overfit Revisited  - 回想基石課程,導致 overfitting 很重要的一點就是 noise - 所以防堵 noise 也是防止 overfit 很重要的一環 ### Dealing with Noise  ## [Principal Component Analysis](https://www.coursera.org/learn/machine-learning-techniques/lecture/9BpTo/principal-component-analysis) ### Linear Autoencoder Hypothesis  - 第 $k$ 個維度的 output $h_k(x)=\sum_{j=0}^\tilde d w_{kj}(\sum_{i=1}^d w_{ij}x_i)$ - 這裡有一些特別的條件 - 不考慮 $x_0$ (即常數項) - 我們把第一層的 weight $w_{ij}^{(1)}$ 寫成 $w_{ij}$,並且和第二層的 weight $w_{ji}^{(2)}$ 強制相等,並把第一層的 weights 寫成 $W\in\mathbb R^{d\times \tilde d}$ - $\tilde d < d$ - 自行推導2 - 我們把 $\sum_\limits{i=1}^\tilde d w_{ij}x_i$ 用 $z_j\in\mathbb R$ 表示,並且用 $z\in\mathbb R^{\tilde d}$ 表示 $\begin{bmatrix}z_1\\z_2\\\vdots\\z_\tilde d\end{bmatrix}$ - 於是 $h_k(x)=\sum_\limits{j=0}^\tilde d w_{kj}z_j$ 可以寫成 $w_k^T z$,其中 $w_k\in\mathbb R^{\tilde d\times 1}$ 是 $W$ 的第 $k$ 個 row - meta-knowledge: $\sum_i a_i b_i$ 可以寫成兩個向量內積 $a\cdot b$ 或 $a^T b$ - > Q: 懶得推了 QQ - 所以整個 hypothesis $h(x)=WW^Tx$ - $W^T$ 就是 encoder 的 weight - $W$ 是 decoder 的 weight ### Linear Autoencoder Error Function  - 這個 $E_{in}$ 對 $w_{ij}$ 來說是四次式,似乎很難找到公式解? 其實還是有公式解,接下來要推導了 - > Q: 這個章節感覺等複習完線代再回來看比較好QQ - $WW^T$ 太複雜,我們可以對她做 **eigen-decomposition** $WW^T=V\Gamma V^T$ (因為 $WW^T$ 會是 positive semi-definite (半正定) matrix) - $WW^T$ 的 rank 最多就是 $\tilde d$ - 也就是說 $\Gamma$ 對角線最多就只有 $\tilde d$ 個非零元素,也就是有 $\tilde d$ 個 **eigen value** 的值。 - $V$ 是 orthogonal matrix 代表 $V^TV=I_d$ - 來看看 error function 的後面那項 $WW^Tx_n=V\Gamma V^Tx_n$ - 把 $x_n$ 乘上一個 orthogonal matrix 代表它只是將 vector 做了一個旋轉或鏡射,但長度不變 - 又乘上 diagonal matrix $\Gamma\in\mathbb R^{d\times d}$,也就是在轉換後對某些維度做了縮放。但 $\Gamma$ 對角線的非零元素只有 $\tilde d$ 個,也就是說某些維度被設成 0 了。 - 再乘上 $V$ 就換回原始坐標系。 - 那 error function 的前面那項 $x_n$ 其實可以寫成 $VIV^T x_n$ - 物理意義就是 旋轉/鏡射之後,不做變換,又旋轉/鏡射回來。 - 所以這個 optimization problem 本身可以轉換成找 $\Gamma$ 以及 $V$ 的最佳化問題。 ### The Optimal $\Gamma$  - 先最佳化 $\Gamma$,再最佳化 $V$ - > Q: 這樣照順序來真的可以找到最佳的 $V,\Gamma$ 組合嗎? - 來看看 $\min_\limits{\Gamma}\sum_{n=1}^N\|VIV^T x_n-V\Gamma V^T x_n\|^2$ 的絕對值這一項 - 可以寫成 $\|V(IV^T x_n-\Gamma V^T x_n)\|^2$ - 乘上 orthogonal matrix $V$ 不影響長度(因為只是旋轉或鏡射),因此可以寫成 $\|IV^T x_n-\Gamma V^T x_n\|^2=\|(I-\Gamma)(V^T x_n)\|^2$ - 要讓各式各樣的 $V^T x_n$ 乘上 $(I-\Gamma)$ 之後的長度都很短,我們會想要 $I-\Gamma$ 有越多 0 越好。 - 那 $\Gamma$ 最佳解就是塞 $\tilde d$ 個 1 在對角線上。$\Gamma=\begin{bmatrix}I_\tilde d & 0\\0&0\end{bmatrix}$ - 接下來最佳化 $V$,$\min_\limits V \sum_{n=1}^N\|\begin{bmatrix}0&0\\0&I_{d-\tilde d}\end{bmatrix}V^T x_n\|^2$ ### The Optimal $V$  - 我們想把最小化問題轉成最大化問題 (等等比較乾淨點) - > Q: slide 上應該要寫成 $\arg\min$ 跟 $\arg\max$ 嗎?? 看不懂為何恆等/等價於 ($\equiv$)??? - $\min_\limits V \sum_{n=1}^N\|\begin{bmatrix}0&0\\0&I_{d-\tilde d}\end{bmatrix}V^T x_n\|^2$ - 而 $V^T x_n$ 的 norm 是定值,因為 $V$ 是 orthogonal matrix - 然後呢@@? - > Q: 還是 $\equiv$ 只是在說:minimize 這個 term 等同於 maximize 那個 term??? - > 就先假設是這樣吧 - 因為 $V$ 不論怎麼變,都不會影響 $V^T x_n$ 的 norm,所以: - 左邊 minimize 的東西就是 transform 之後的 vector 要留下的 dimensions 的長度平方 - 那因為留下的 dimensions 和拿掉的 dimensions 的長度平方 加總會相等,因此 minimize 左邊,等同於 maximize 右邊。 - 現在的 objective $\max_\limits V \sum_n \|\begin{bmatrix}I_\tilde d&0\\0&0\end{bmatrix}V^T x_n\|^2$ - 那個 diagonal matrix 又變回 $\Gamma$ 了 - > Q: 本來是要 minimize reconstruction error,可以說現在變成 maximize 轉換後的 feature 的平方? - $\tilde d=1$ 的時候,只有第一個 row $v$ 有影響 - $v\in\mathbb R^{d}$, $x_n\in\mathbb R^{d}$ - $\|v^T x_n\|^2=(v^T x_n)^T(v^T x_n)=(x_n^T v)(v^T x_n)=v^T x_n x_n^T v$ - 這個推導好像有點殺雞用牛刀了,$v^T x_n$ 是 scalar 所以直接寫 $=v^T x_n x_n^T v$ 就好啦,不過這推導應該可以 generalize 到 $\tilde d>1$ 的情況 - 利用[基石教過的 Lagrange Multiplier](https://hackmd.io/@johnnyasd12/Bk_sF2_CB/https%3A%2F%2Fhackmd.io%2F%40johnnyasd12%2FHyse98wCS),可以把有條件的最佳化問題改寫 - meta-knowledge: high-level 的說 Lagrange Multiplier 應該是:objective function 要 parameter 走的方向,要跟 constraint 要 parameter 走的方向相反。 - 也就是說 $\sum _n x_n x_n^T v$ (objective 方向)要和 $-v$ (constraint 的方向) 相反 - 即 $\sum_n x_n x_n^T v=\lambda v$ - 左邊可以寫成 矩陣 $X^T X$ 乘上 $v$ - > Q: 怎麼推導出可以寫成矩陣? - 那不就是 eigen value $\lambda$ 跟 eigen vector $v$ 嗎 - 而且要是最大的 eigen vector,等等會推導(?) - > Q: 等等推導@@? - $\tilde d>1$ 的情況也一樣,要找最大的那些 eigen vectors ### Principal Component Analysis  - 跟前面的方法很類似的一個方法 PCA,他希望的是 **maximize variance after projection** - review 我們 maximize 的是 feature after projection 的平方 - 那怎麼做到 PCA 一樣的事呢?其實直接在 input data 減去平均值以得到平均為 0 的資料即可。 ### Fun Time: Objective Value  - PCA 這個章節總覺得沒有全懂@@ 改天重看好了 ### Summary  測試 transpose - $W^T W^\top W^\bot W^\intercal W^\mathsf T$
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up