咳咳,又到了博文時間,這一課的內容相對較少,所以就相對較快的來總結來博文啦,哈哈哈
廢話不多說了,開始寫吧,這一課的內容主要有三個部分,第一部分是window classification,第二部分是關於softmax的求梯度的tips,第三部分是Neuron Network 的一個簡單介紹。
在這堂課開始的時候老師講了一句話很經典,特此抄錄下來:The large context you get, the more order of the words you ignore. The less you know whether that word was actually in a position of a adv adj or noun. 你的context選取的越大,越多的單詞順序就會被忽略,越不可能知道這個單詞是adj, adv還是noun。
Classification intuition
這一部分簡要的介紹瞭如何進行分類,一個簡單的辦法就是用softmax進行分類
W是softmax的weight matrix用來進行分類。分子的y代表ground truth的index,分母是將所有可能的class的值相加,最後求得一個概率。俺們的目標當然是使得這個概率越大越好啦,所以構造cost function或者loss function是這樣的
我們使用到了極大似然估計(maximize likelihood estimation)就是假定所有事件發生是IID的,然後這些事件同時發生的概率就是它們各自概率的乘積,我們的目標就是求得使這個概率最大的參數,這裏取log然後求和,利用到了log求和就是其parameters求積的性質。前面加了個符號,顯然我們是要求使其最小的Weight Matrix。
之後又講了一邊上一堂課的內容Loosing generalization by re-training word vectors就是要不要更新word vectors呢?
slide裏寫得很好:If you only have a small training data set, don't train the word vectors. If you have a very large dataset, it may work better to train word vectors to the task.
原因上一節課就講過了,就不再贅述了。
Side note
課上講了幾個術語,讓人不是那麼迷惑。
1. Word vector matrix L is also called lookup table.
2. Word vectors = word embeddings = word representations他們大概都是同一個意思哦!
Window Classification
這下終於到了本課的其中一個重點了。爲什麼需要window classification呢?因爲不用window classificaiton容易出現ambiguity這種問題呀!
那麼這東西怎麼實現的呢?Instead of classifying a single word, just classify a word together with its context window of neighboring words.
給center word定義一個label然後連接所有他周圍的word vector使其形成一個更長的vector。
然後怎麼進行window Classification呢老樣子還是用我們熟悉的softmax只是這時候的word vector不再僅僅是center word vector並且要concatenating all word vectors surrounding it。
具體怎麼做呢?slides裏給出了tips,但我還是覺得推的太簡單所以我又手推了一遍。
一下是推導過程:
我tip 2推倒的不太對,課上的意思是使用chain rule,很簡單,不用多說了。
tip 4推出來delta怎麼得來的。
最後推了一個對softmax weights W求導的計算方法。
Basic neural networks
A single neuron簡單的說就是多個softmax的組合。
多加幾個out layers就使得結構更復雜,能力也更強。
再增加一個或多個hidden layers就更牛逼了,slides講的很詳細,UFLDL上講得也挺好,鏈接,就不贅述了。
Intuition of back-propagation
課上推薦的那個四頁的論文簡直就是糊弄人嘛,其實就是個BP的科普,實質性的內容很少。裏面比較經典的句子我摘抄下來了:
The procedure repeatedly adjusts the weights of the connections in the network so as to minimize a measure of the difference between the actual output vector of the net and the desired output vector.
Connections within a layer or from higher to lower layers are forbidden, but connections can skip intermediate layers.
如果想稍微詳細瞭解BP的話還是看UFLDL上的簡介吧!鏈接
BP的思路就是從output layer往最前一層倒推,for each node i in layer l, we would like to compute an "error term" that measures how much that node was "responsible" for any errors in our output.
給每一層每一個edge計算responsible for any errors in our output,好無辜的edges
從最上一層說起,他的思路就是,如果你這個edge輸入的z大,那麼你對error的貢獻也就大,計算responsible就是將error對每一個edge的z求導,這樣就把最後一層的edges上的responsibles求出來了。
下一層的responsible呢,就是先把所有上層的responsibles求weights average其中weights就是edges上的W_ij然後再乘上f'(z)
然後就是J(W,b;x,y)對W_ij求導啦,也很簡單使用chain rule其中要注意的一點就是這一層的x向量就是之前一層的a向量,不然怎麼老感覺答案不對(- -)。
然後下面的公式是使用簡潔的matrix表示方法很好看,也很簡潔。
最後下面的pseudo-code很有借鑑意義,在自己code的時候可以參考着寫。