Training a neural network efficiently with minibatches