Keras conv1d layer parameters: filters and kernel_size

99封情书 提交于 2019-12-02 14:42:12

You're right to say that kernel_size defines the size of the sliding window.

The filters parameters is just how many different windows you will have. (All of them with the same length, which is kernel_size). How many different results or channels you want to produce.

When you use filters=100 and kernel_size=4, you are creating 100 different filters, each of them with length 4. The result will bring 100 different convolutions.

Also, each filter has enough parameters to consider all input channels.


The Conv1D layer expects these dimensions:

(batchSize, length, channels)

I suppose the best way to use it is to have the number of words in the length dimension (as if the words in order formed a sentence), and the channels be the output dimension of the embedding (numbers that define one word).

So:

batchSize = number of sentences    
length = number of words in each sentence   
channels = dimension of the embedding's output.    

The convolutional layer will pass 100 different filters, each filter will slide along the length dimension (word by word, in groups of 4), considering all the channels that define the word.

The outputs are shaped as:

(number of sentences, 50 words, 100 output dimension or filters)   

The filters are shaped as:

(4 = length, 300 = word vector dimension, 100 output dimension of the convolution)  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!