CNN – How to Work with Multiple Filter Region Sizes: 2, 3, and 4

classificationconv-neural-networkconvolutiondeep learningmachine learning

I mention learn convolutional neural networks (CNN) for classification of sentences made by Yoonkim.

I am still confused about the size of the filter and how convolution works .

What do filter_h = 5 with filter_hs = [3,4,5], whether filter_h is the maximum length for each filter_hs?? how it works?

To get the image shape, the longest maximum sentence in this case is 56 so 56 + 2 * (5-1) = 64 .., What does number 2 mean? Where is number 2 obtained?

Best Answer

I am still confused about the size of the filter, how convolution it works

Here is a great illustration from Stanford's deep learning tutorial (also nicely explained by Denny Britz).

enter image description here

The filter is the yellow sliding window, and its value is:

\begin{bmatrix} 1 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 1 \end{bmatrix}

Another neat visualization of convolutions (and deconvolutions a.k.a. transposed convolutions): https://github.com/vdumoulin/conv_arithmetic

enter image description here

enter image description here

to get the image shape, the longest maximum sentence in this case is 56 so 56 + 2 * (5-1) = 64 .., what does it mean number 2 ?? where number 2 is obtained?

Padding on the left and on the right of the sentence.