carmocca:

But when every batch can have a different length, you would be using the same learning rate for a loss averaged over 1 sample than one averaged over a 1000 samples.


For both batches you’ll get unbiased estimates of global dataset’s gradients directions. Estimators from small batches will have higher variance, but I don’t think that this is a problem with realistic batch sizes, as if I’m not mistaken, sampling errors reduce as 1/sqrt(batch_size).
There is also shuffling to smooth steps taken in the long term.