# Filter dimensionality in ConvNNs

This is a major confusion for me - I've always thought filters (those small sliding windows size 3x3 or 5x5) are strictly 2D, this among other is specified in Caffe API:

kernel_size / kernel_h / kernel_w. The filter dimensions, given by kernel_size for square filters or kernel_h and kernel_w for rectangular filters

Now, I've never been 100% clear on what these convolutions mean (taken from Matt Zeiler's article (Visualizing and Understanding Convolutional Networks) and how they were obtained:

After searching it turned out that filters can be 3D?? How does it work then? I found a bit of information on CS 231n course, but it's not explained in detail anywhere.

## 1 Answer

The diagram below Example 2 in this CS231 lecture is a good visualization of how filters work: http://cs231n.github.io/convolutional-networks/. Since each layer of a ConvNet has a depth corresponding to the number of filters (in an input RGB image, for example, the depth of the input layer would be 3), each filter of size $k\times k$ applied to a layer of delth $d$ slides over a volume of $k\times k\times d$ (note that the filter stays at a constant depth).

• but doesn't this mean that for a layer size nxnx3 we will have 3 different filters kxk each?
– Alex
Mar 30 '17 at 14:27
• The number of filters is the depth $d'$ of your output layer, while the depth of each of those filters is the depth $d$ of your input layer Mar 30 '17 at 15:30
• but then why doesn't caffe implement them (here's from API): see the excerpt from the API
– Alex
Mar 31 '17 at 11:33