How are the Convolution kernels learned? As I went through the basics of machine learning, I failed to understand how do the Convolutional layers in a CNN learn the convolution kernels. After looking at first few tutorials, I thought the kernels were fixed: for example, there was a 2D kernel which extracts vertical lines, another one extracted horizontal lines etc. Later on I realized that kernels are learned by the network and not fixed. 

Is there a good explanation on how the learning goes, how does the backpropagation work (compared to fully connected layers), what is the optimization function, etc.? 

p.s.
Let this be an example function to explain: https://keras.io/layers/convolutional/.
Sometimes the kernel function is very difficult to choose in a fixed form even if once found it would be easier. It can be learned to map the data in a features space (Hilbert space) through an Convex Optimisation method such as Semidefinite programming, using Hyperkernels, etc.

Some very usefull papers for your question can be found here:

Learning the Kernel via Convex Optimisation

Learning the Kernel Matrix with Semidefinite Programming

Learning the Kernel with Hyperkernels

Learning the Kernel Function via Regularization

I hope that answers your question