I am new to CNN. What I have learned so far about the filters is that when we are giving a training example to our model, our model updates the weights by gradient descent to minimize the loss function. So my question is how the weights are retained for a particular class label?

The question is vague as my knowledge is vague. It's my 4th hour to CNN.

For example, if I am talking about the MNIST dataset with 10 labels. Let's say I am giving 1 image to my model initially. It will have a bigger loss for the forward pass. Let's say now it came for the back pass and adjusted the weights for and minimized the loss function for that label. Now, when a new label arrives for training, how will it update the weights for filters which have already been updated according to the previous label?

  • $\begingroup$ Hi and welcome to AI SE! Your question is indeed unclear and vague. Are you familiar with gradient descent and back-propagation? $\endgroup$
    – nbro
    Mar 31, 2020 at 11:08
  • $\begingroup$ Hey I read about it from some links. Can you provide me an easy to go source ? $\endgroup$
    – kd369
    Mar 31, 2020 at 17:59

1 Answer 1


Besides the last layer rest of the weights are shared among all classes. When an image is passed to the network all weights are updated accordingly. The only weights that are directly responsible for one specific class are the ones of the final layer. The rest of the weights are updated to find the best values to minimize the average loss for all classes.

To rephrase there aren't "filters" in convolutional layers that are specific for a single class. They are used to extract features so that the final layer can make the final prediction (which has weights for each specific class).

I'd suggest you look a bit into how gradient descent and backpropagation works.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .