In most implementations of neural networks the features are scaled to make the optimization of the loss function as stable as possible. Mostly a min-max scaler is used. Alternatively, there is also a standard scaler.

Why do you calculate the mean and standard deviation offline over the complete dataset before training? Couldn't this be calculated per batch or even per file? What is the disadvantage? Why doesn't anyone do this?

  • 2
    $\begingroup$ Just to clarify, you're wondering why we couldn't take a batch from the data, compute the mean and standard deviation of each feature over that batch, and then scale using that (so the means from each batch could potentially be different)? $\endgroup$
    – htl
    Commented Apr 9, 2021 at 13:59


You must log in to answer this question.