title: Pytorch: How does SGD with momentum works when optimizer has to call zero_grad() to help accumulation of gradients?
body: <p>In pytorch, the backward() function accumulates gradients and we have to reset it every mini-batch by calling optimizer.zero_grad(). In this case, how does the SGD with momentum works when actually momentum SGD updates the weights using exponential average of some past mini-batches. </p>
  
  <p>For a beginner in Pytorch, I am confused. Doesn't it require to have past gradients to perform updates.</p>