fix bug in stochastic gradient descent