天天看點

Unsupervised Learning: Deep Auto-encoder

Auto-encoder

它的思想是,找一個encoder,比如input一張image,經過encoder,output一個code,它的次元要遠比input小,那這個code就代表了這個input某種精簡的有效的representation。

Unsupervised Learning: Deep Auto-encoder

但是現在問題是非監督的,我們可以找到一堆input但是不知道output是什麼,那我們可以先learn一個decoder,它可以input一個vector然後output一個image。你也沒辦法train decoder,因為你也隻有output。

Unsupervised Learning: Deep Auto-encoder

二者單獨都不能train,但是可以把二者聯系起來一起train。

Unsupervised Learning: Deep Auto-encoder

從PCA中,input一個image x,乘上weight得到component,component再乘以weight的transports,得到x^,minimize x和x^

這裡面隻有一層的hidden layer,hidden layer的output就是code

Unsupervised Learning: Deep Auto-encoder

我們可以用gradient decent來解PCA,但是它隻有一個hidden layer,也可以将它改成很多的hidden layer。

Unsupervised Learning: Deep Auto-encoder

中間會有一個特别窄的layer,它有特别少的neuron,這個layer的output就代表了一組code。input到bottle是encode,bottle到output是decode。左右兩邊的weight沒必要互為transport,可以直接train

Unsupervised Learning: Deep Auto-encoder

結果圖如下;

Unsupervised Learning: Deep Auto-encoder
Unsupervised Learning: Deep Auto-encoder

Auto-encoder ——Text Retrieval

可以将一篇文章壓成一個code,假設我們想做文字搜尋,将每個文章表示成一個點,輸入一個查詢的詞彙,也變成空間的一個點,然後與文章的點坐cos similarity,距離最近的話就會檢索這個document。那現在的問題就是這個文章的vector你表示的好不好。

Unsupervised Learning: Deep Auto-encoder

表示成vector最簡單的方法就是LSA,用那種可以表示所有文字的vector,包含就是1不包含就是0.你也可以給每個element乘上一個weight,代表那個詞彙的重要性。但是這個方法沒辦法知道語義上面的事情,比如apple和orange都是水果等。它認為所有的word都是獨立的。

Unsupervised Learning: Deep Auto-encoder

可以用auto-encoder:将一篇文章經過encoder把它壓成二維的,每個document會被标成某一類,結果圖如下,同一類document在一起。

Unsupervised Learning: Deep Auto-encoder

Auto-encoder——Similar Image Search

以圖找圖,計算image的query和其他image的pixel的相似程度,這樣的結果不太好,

Unsupervised Learning: Deep Auto-encoder

那可以用auto-encoder将image變成code,然後在code的基礎上進行搜尋。又因為是非監督的,可以collect很多data。

Unsupervised Learning: Deep Auto-encoder

reconstruct的過程就是與上述過程相反,結果如下:

Unsupervised Learning: Deep Auto-encoder
Unsupervised Learning: Deep Auto-encoder

Auto-encoder——Pre-training DNN

在train一個NN時,很難找初始化參數,假設想要得到下面這個DNN的初始化參數,用auto-encoder的方法就叫做Pre-training。

Unsupervised Learning: Deep Auto-encoder
Unsupervised Learning: Deep Auto-encoder
Unsupervised Learning: Deep Auto-encoder

需要注意的是,在這auto-encoder中,code比input大,這有可能會讓code硬背起來input然後再輸出,那就什麼都沒有learn到。是以在這種情況下要加一個很強的regulation在這個1000維上,就是希望這1000維裡某幾維是有值的,其他的沒有值。

然後求第二層的weight,

Unsupervised Learning: Deep Auto-encoder
Unsupervised Learning: Deep Auto-encoder
Unsupervised Learning: Deep Auto-encoder

然後反向微調,稱作:Find-tune by backpropagation。現在train的技術進步之後幾乎不用pre-training了。但是如果你隻有少量的label data,你可以用大量的unlabel data初始化w1,w2,w3,最後的label data稍微調整一下就好。

De-nosing auto-encoder

Unsupervised Learning: Deep Auto-encoder

learn出來的NN會更加魯棒。

Auto-encoder for CNN

根據CNN的過程我們可以知道encoder和decoder的過程如下:

Unsupervised Learning: Deep Auto-encoder

那unpooling的過程是怎麼樣的呢?

首先就是在polling的适合,除了選出最大的那個點,還要記錄一下,最大的那個點是在什麼部位選出來的:

Unsupervised Learning: Deep Auto-encoder

接下來做unpooling時,要将比較小的matrix變成大的,将值放到對應的位置上,其他位置補0就好:

Unsupervised Learning: Deep Auto-encoder

在keras中,你不用記錄之前的位置,就是repeat那個記錄下來的最大值

接下來是比較難了解的Deconvolution,事實上deconvolution也就是convolution:

Unsupervised Learning: Deep Auto-encoder

這是convolution。

原本想的deconvolution可能是如下的:

Unsupervised Learning: Deep Auto-encoder

其實它是可以用convolution來表示的,将三個值當做輸入,再分别補上幾個0:

Unsupervised Learning: Deep Auto-encoder

其實第一個過程和第三個過程是完全一樣的,而且第三個過程的結果跟第二個過程的結果是完全一樣的。需要注意的是,weight是完全相反的(由紅藍綠變成綠藍紅),這個操作也是一個從convolution的過程的。

繼續閱讀