I have been trying to develop a convolution neural network following some guides online. However, most guides I have encountered gloss over an important detail, which is how to programmatically represent the weights in a CNN.

As far as I understand, in a "regular" neural network, the weight of a connection is a numerical value, which is adjusted in order to reduce the error; then back-propagation is used to further update the weights, reducing thus the error, etc.

However, in a CNN, the input is an array of numbers (the image), and a subset of those (the filter) to calculate the mean error, by multiplying the filter pixels by the original pixels.

So, is there a weight neuron for each filter (kernel or feature map) of the image? Or is a single weight neuron represented by the sum of all the mean error's calculated from convolving the filter over the receptive field, such that you have one value, in the end, that is the total error for the entire image?

  • 1
    $\begingroup$ All of your confusions will be answered after watching the nice lecture: youtube.com/watch?v=AQirPKrAyDg $\endgroup$ – Ehsan M. Kermani Apr 14 '17 at 0:50
  • $\begingroup$ this video really helped explain many things, but i struggled a bit with how he acquired his filters for training....like when you train the network initially are the filters just pre-classified images? or part's of an image? such as if i want to train a facial recognition cnn would the network be trained on pictures of entire faces as filters, or parts of a face? $\endgroup$ – D3181 Apr 15 '17 at 19:55
  • $\begingroup$ on a 2d image, say 32 by 32 you prespecify a filter size 2 for example and compute the dot product/ convolution across all 2 by 2 squares in 32 by 32 image. $\endgroup$ – Ehsan M. Kermani Apr 15 '17 at 20:28
  • $\begingroup$ ok so the process of training is choose an image, label it as whatever classification it is, choose filters for that labeled image (eye brows, mouth etc)..use a dot product between the filters and training image and use back propagation to reduce the squared mean error? $\endgroup$ – D3181 Apr 17 '17 at 14:01
  • $\begingroup$ Seems you've confusion filter to be an actual filter! well ,it's not. Use kernel instead. Also you don't specify what convet to learn (eye brows etc.) you specify a kernel ( say 2 by 2) and slide it over all the places it can fit in your picture. Irony is abstractions (like detecting mouth etc.) are learned in different layers by themselves. $\endgroup$ – Ehsan M. Kermani Apr 17 '17 at 16:32

In convolutional layers the weights are represented as the multiplicative factor of the filters.

For example, if we have the input 2D matrix in green

enter image description here

with the convolution filter

enter image description here

Each matrix element in the convolution filter is the weights that are being trained. These weights will impact the extracted convolved features as

enter image description here

Based on the resulting features, we then get the predicted outputs and we can use backpropagation to train the weights in the convolution filter as you can see here.

| improve this answer | |
  • $\begingroup$ so basically the filters are the weights? $\endgroup$ – Khan May 10 at 12:59
  • 1
    $\begingroup$ @khan, yes, they are weights. Further, every output value is the linear combination of the weights multiplied by the values around the value (which is then passed through an activation function) $\endgroup$ – Robert Lugg Jul 9 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.