I'm looking on a given solution of the first assignment of cs231n course.

Down below a snippet from the loss function. I don't really understand lines 140-143. Can you explain why dscores (the derivative of scores) is calculated like that?

enter image description here

  • $\begingroup$ What is y? and N in conjunction to lim_scores? $\endgroup$ Dec 22 '18 at 21:04
  • $\begingroup$ I was looking for the answer to this as well. I think the answer is in section Computing the Analytic Gradient with Backpropagation of this link. $\endgroup$
    – CaTx
    Sep 3 '21 at 13:47

Be aware that posting code in images very annoying to copy/paste and it's bad for web reference ment.

This is due to the derivative of the softmax, but to me it's seems fishy.

If $S$ is the softmax vector, then the Jacobian $DS$ consists of $S_j(\delta_{ij}-S_i)$. This could explain the -=1 part, but not the /=N, and not the shape either.


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.