keras中Convolution1D的使用


keras中Convolution1D的使用

這篇文章主要說明兩個東西,一個是Convolution1D的介紹,另一個是model.summary()的使用。

首先我先說下model.summary(),此方法可以打印出模型的信息,讀者可以查看每層輸出內容。

接下來就說下Convolution1D的使用了,Convolution1D一維卷積,主要用於過濾一維輸入的相鄰元素,官方文檔是這樣的

keras.layers.convolutional.Convolution1D(nb_filter, filter_length, init='glorot_uniform', activation=None, weights=None, border_mode='valid', subsample_length=1, W_regularizer=None, b_regularizer=None, activity_regularizer=None, W_constraint=None, b_constraint=None, bias=True, input_dim=None, input_length=None) 

然后官方給出的事例是這樣的

# apply a convolution 1d of length 3 to a sequence with 10 timesteps,
# with 64 output filters
model = Sequential()
model.add(Convolution1D(64, 3, border_mode='same', input_shape=(10, 32)))
# now model.output_shape == (None, 10, 64)

# add a new conv1d on top
model.add(Convolution1D(32, 3, border_mode='same'))
# now model.output_shape == (None, 10, 32)

然后用print(model.summary())輸出是這樣的:

 

   下面我就圍繞着上面代碼簡單介紹下:當把該層作為首層時,需要說明 input_shape

input_shape=(10, 32)簡而言之就是10個32維的向量了,nb_filter : 卷積核的數量,也是輸出的維度。filter_length : 每個過濾器的長度。
首先我們先看第一個卷積層,輸出shape很容易理解,因為有64個卷積核,所以輸出也就是64,接下來我們看下參數:其實可以這么理解,我們把例子中(10,32)的信號進行1D卷積相當於對其進行卷積核為(filter_length, 32)的2D卷積

好了,就醬吧

 
          

轉載於:https://www.cnblogs.com/qianboping/p/6516639.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM