In Stanford’s CS231n first module titled: “Optimization: Stochastic Gradient Descent,” they describe how loss for multiclass SVM without regularization is described as:

*L*_{i} = ∑_{j ≠ yi}[max(0,*w*_{j}^{T}*x*_{i}−*w*_{yi}^{T}*x*_{i}+1)]

For their three-dimensional example across (W). Breaking this down across each row of (W), we get:

*L*_{0} = max (0, *w*_{1}^{T}*x*_{0} − *w*_{0}^{T}*x*_{0} + 1) + max (0, *w*_{2}^{T}*x*_{0} − *w*_{0}^{T}*x*_{0} + 1)

*L*_{1} = max (0, *w*_{0}^{T}*x*_{1} − *w*_{1}^{T}*x*_{1} + 1) + max (0, *w*_{2}^{T}*x*_{1} − *w*_{1}^{T}*x*_{1} + 1)

*L*_{2} = max (0, *w*_{0}^{T}*x*_{2} − *w*_{2}^{T}*x*_{2} + 1) + max (0, *w*_{1}^{T}*x*_{2} − *w*_{2}^{T}*x*_{2} + 1)

*L* = (*L*_{0} + *L*_{1} + *L*_{2})/3

These can be visualized as the following:

So the thing that I don’t get is… Nope. It all makes sense. I thought they wrote that you could “reorganize” the errors to get a convex shape, however this is wrong – as the giant letters **“sum”** clearly state. This is a sum of average loss error across all dimensions.

More interesting is this: the graph shown is not differentiable! It is a step-wise function. Mathematically, this isn’t sound, but *subgradients* still exist.

Other notes from “Optimization: Stochastic Gradient Descent” and “Backprop, Intuitions”:

- the derivative on each vaiable tells you the sensitivity of the whole expression on its value1.
- in the “real-valued circuts” example1, backprop can be thought of as gates communicating to eachother whether they want their outputs to increase or decrease, and how strongly, to make the final output higher.
- backprop in practice should be done while caching forward-pass variables
- gradients add up at forks according to the
*multivaraite chain rule*(states that if a variable branches out to different paths of the circut, then gradients that flow back to it will accumulate via addition). - “add gates” in a NN distribute gradients evenly to all inputs regargless of forward pass inputs
- “max gates” route the gradient to exactly the maximum input variable.
- “multiply gates” calculate local gradients. In
`x = 3`

,`y = -4`

,`f(x,y) = x * y == -12`

, with a gradient of`2`

, the local gradient for each input is calculated:`dx = y*grad == -4 * 2 = -8`

,`dy = x * grad == 3 * 2 = 6`

- as a corollary, this means that small values will get large local gradients and vice-versa. This makes sense as the local gradients move variables them towards a common gradient. This makes preprocessing and initial weights very important. For more on initial weights, see Xavier initialization.

- for vectorized optimizations we do the same as with scalars, but we have to pay attention to dimensionality and transpose operations.
- tensor-tensor multiply gradients (including matrix-matrix, matrix-vector, and vector-vector) are dot products as forward passes and transpose dot products for gradients. Paying attention to input dimensionality and ensuring that gradient dimensions match is very important.