Efficient Minibatch Training for Stochastic Optimization