← Instacart Interview Insights
I said 'yes' pretty quickly because MSE is convex and I figured both optimizers are just finding the same minimum.
Clarify that with MSE loss, the optimization problem is convex, so both batch gradient descent and SGD converge to the global minimum given appropriate learning rates and sufficient iterations. However, they may take different paths and have different convergence rates, and in practice, SGD may oscillate around the minimum due to noise. Emphasize that the final point should be the same in expectation, but stochasticity can lead to small differences unless learning rate is decayed.
Pro tip: Mention that while the theoretical global minimum is the same, SGD's noise can cause it to settle at a slightly different point unless you use learning rate decay or averaging. This shows you understand practical nuances beyond textbook theory.
State that with MSE loss, the objective is convex (for linear models) or non-convex (for neural networks), but assume convexity for this discussion. For convex problems, there is a unique global minimum.
Batch gradient descent computes the exact gradient over the entire dataset and moves deterministically toward the global minimum, converging to it given a suitable learning rate and enough iterations.
SGD uses noisy gradients from mini-batches, so it follows a stochastic path. With a fixed learning rate, it oscillates around the minimum; with a decaying learning rate, it converges to the global minimum in expectation.
In theory, both converge to the same global minimum for convex MSE. In practice, SGD may end up very close but not exactly at the minimum due to noise, unless learning rate is annealed or averaging is used.
If the model is non-convex (e.g., neural networks), MSE loss may have multiple local minima, and batch GD and SGD could converge to different local minima depending on initialization and batch order.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.