Filters in convolution

On the tensorflow official website it is said that the filters are integers and it can be arbitrary, so I would like to know what kind of filters are in use in convolution layer. I know about filters but what exactly are these filters…does the number represent different kind of filters or are they same. If same then why are we using 64 or 32 or 128.

If I can get any idea or resource to read about it will be really helpful.

Thanks in advance.

Hi Ali,

The filters parameter corresponds to the number of filters (kernels) applied in this convolutional layer. Hence, they should be specified as integers. Each of these filters will be applied to the data array (e.g., image) to obtain a filter response (features). They are applied using a convolution operation, which is a weighted mean using the filter as a sliding window. Each filter application will result in some features of the image, and then the filter responses are concatenated. That is why the number of filters determines the depth dimension of the output tensor.

In this article, you can find a comprehensive introduction to the convolution operation, filters, and variations of convolutions that are typically used.

I hope this can help you.

3 Likes

Hi Pablo,

Thank you for your response.

As per my understanding, if we mention 64 as a filter then 64 different kinds of filters will be used for convolution on images and then it will be concatenated, is that correct?

Regards,
Ali Asgar Zakir

1 Like

Hi @Ali_Asgar_Zakir.

Yes, this is correct. Each of the filters is a unique, usually randomly initialized matrix of a specified size. During the training, we find optimal values to fill these matrices with.

Does this make sense?

1 Like

Hi Yurij,

That sounds perfect to me.

Thanks to you for the clarification.

1 Like

Hi @Ali_Asgar_Zakir,

There are different types of filters (such as edge and sharpening filters) but the magical thing about CNN is that it will automatically determine the appropriate filters that are right for the dataset.

During the training, the filter values are updated (just like weights are in densely connected neural networks). At each step of the training, and as images are being fed into CNN, the values of each filter are updated slowly towards the values that minimize the loss/cost function.

The number of filters determines the number of feature maps that will be produced by the convolutional layer. You can also think of filter values as weights like in other standard neural networks.

Also about why many people choose the number of filters in this fashion 16, 32, 64, 128, 256, 512…, there is honestly no proper answer. But it has been shown (I do not remember exactly where I read it) that doubling filters at layer after layer can work well in most cases. But it is far good to use tools that are well suited for hyperparameters tuning like Keras Tuner.

If you would like to play with filters and the convolutional process, I invite you to check the following 3 links:

2 Likes