I'm trying to better understand convolutional neural networks better by writing up Python code that doesn't depend on libraries (like Convnet or TensorFlow), and I'm getting stuck in the literature on how to choose values for the kernel matrix, when performing a convolution on an image.
I'm trying to understand the implementation details in the step between feature maps in the image below showing the layers of a CNN.
According to this diagram:
The kernel matrix kernel "steps" over the image, creating a feature map, where each pixel is the sum of all element-wise products between each weight of the kernel (or filter matrix) and the corresponding pixel value of the input image.
My question is: how do we initialize the weights of the kernel (or filter) matrix?
In the demonstration above, they are simply 1s and 0s, but I assume this is simplified from the diagram's sake.
Are these weights trained in some preprocessing step? Or chosen explicitly by the user?