While dealing with stochastic gradient descent, I got confused by several sources which explained it quite differently.
- One source explained stochastic gradient descent as standard gradient descent approach but with substantial smaller training set.
- The other approach first sums the gradients of all training set and then multiplies with learning rate and updates it. $Q_{t+1}<-Q_t - \tau * \frac{n}{|S|}*\sum_{j\in S}\nabla L_j(Q_t)$
What is the difference? and How does it work with matrices since I take just couple of training examples? (see example below)
Here is an example: I have sparse matrix M with user x movies where the value in the matrix represents how much the user rates the movie. I decomposed it into matrices P and Q and using stochastic gradient descent I want to optimize P and Q by minimizing the loss function. Each value of M can be reconstructed by multiplying vector of Q and P.
Let's say I take batches of 10 so it means I take just 10 values from matrix M and respective rows and columns of P and Q which I will optimize. If I take the second approach there is sum of gradients of all point and then I do the update but how can I sum those vectors since they do not correspond to the same place in matrix Q or P? In this case, should I then just make new P and Q just with vectors that corresponds to taken values of M? but then it does not make sense because I should optimize the whole Q and P matrices right?
I hope I made it clear enough.