My question is about kernels or filters of convolutional layers in CNN. We can specify the filter size and how many filters there should be in one convolutional layer. But we never specify the values of filters. I know the filters are like matrix used to go through an image.
I wonder if there is an algorithm to generate the filters and optimize them during training. Thanks.
The main purpose of Deep convolution neural network is to learn those numbers. The so called kernel values in each filter, such that it extracts the right information from the image.
At the outset, to explain in simple terms, lets say, we have 3*3 filter, it initially assigns all the 9 values to 0.5 . It runs over the image and produces the next level of feature map by doing the math, for simple terms lets keep it as multiplication.
It does the final layer of activation and final prediction for the probability which in turn decides the number of classes. If the model doesn't predict well for that batch/sample, it propagates, the loss backwards and changes the values of these kernel (9 values).Its not just these 9 values, but this process is carried out for number of filters of convolution you have at each level.
Now to efficiently make the training process, you can initialize these values through various different methods.
If you are using keras, have a look at kernel intializers here https://keras.io/initializers/