Question: I am about to train a big LSTM network with 2-3 million articles and am struggling with Memory Errors (I use AWS EC2 g2x2large).

I found out that one solution is to reduce the `batch_size`. However, I am not sure if this parameter is only related to memory efficiency issues or if it will effect my results. As a matter of fact, I also noticed that `batch_size` used in examples is usually as a power of two, which I don't understand either.

I don't mind if my network takes longer to train, but I would like to know if reducing the `batch_size` will decrease the quality of my predictions.

Thanks.

Answer: 
I feel the accepted answer is possibly wrong. There are variants in *Gradient Descent Algorithms*.

1. **Vanilla Gradient Descent**: Here the Gradient is being calculated on all the data points at a single shot and the average is taken. Hence we have a smoother version of the gradient takes longer time to learn.
2. **Stochastic Gradient Descent** : Here one-data point at a time hence the gradient is aggressive (noisy gradients) hence there is going to be lot of oscillations ( we use Momentum parameters - e.g Nesterov to control this). So there is a chance that your oscillations can make the algorithm not reach a local minimum.(diverge).
3. **Mini-Batch Gradient Descent**: Which takes the perks of both the previous ones averages gradients of a small batch. Hence not too aggressive like SGD and allows Online Learning which Vanilla GD never allowed.

The smaller the Mini-Batch the better would be the performance of your model (not always) and of course it has got to do with your epochs too faster learning. If you are training on large dataset you want faster convergence with good performance hence we pick Batch-GD's. 

SGD had fixed learning parameter hence we start other Adaptive Optimizers like Adam, AdaDelta, RMS Prop etc which changes the learning parameter based on the history of Gradients.
A couple of papers have been published showing – and conventional wisdom in 2020 seems to still be persuaded— that, as [Yann LeCun](https://twitter.com/ylecun/status/989610208497360896) put, large batches are bad for your health.

Two relevant papers are

* [Revisiting Small Batch Training For Deep Neural Networks, Dominic Masters and Carlo Luschi](https://arxiv.org/abs/1804.07612) which implies that anything over 32 may degrade training in SGD.

and

* [On Large-batch Training For Deep Learning: Generalization Gap And Sharp Minima](https://arxiv.org/abs/1609.04836)

which offers possible reasons. To paraphrase badly, big batches are likely to get stuck in local (“sharp”) minima, small batches not. There is some interplay with choice of learning rate.