# Batch Normalization

**URL:** <https://community.deeplearning.ai/t/batch-normalization/10589>\
**Category:** Improving Deep Neural Networks: Hyperparameter tun\
**Tags:** coursera-platform\
**Created:** [May 31, 2021, 7:12am UTC](https://community.deeplearning.ai/t/batch-normalization/10589 "2021-05-31T07:12:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bgoyal](https://avatars.discourse-cdn.com/v4/letter/b/d6d6ee/32.png) [@bgoyal](https://community.deeplearning.ai/u/bgoyal)\
**Post date:** [May 31, 2021, 7:12am UTC](https://community.deeplearning.ai/t/batch-normalization/10589/1 "2021-05-31T07:12:06Z")

</div>

I’m a bit confused by the notation in this slide. I was of the opinion that the normalization would be carried out separately for each training example (so m means, m variances). But the summation variable i seems to be over the training examples. Do we calculate the mean and variance of all training examples together and use those values?

 ![Screenshot 2021-05-31 at 12.39.00 PM](https://global.discourse-cdn.com/dlai/original/2X/f/f775a42bc390e5751065402b1039abec21661202.jpeg)

---

<div class="post-metadata">

**Author:** ![nramon](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/nramon/32/129097_2.png) [@nramon](https://community.deeplearning.ai/u/nramon)\
**Post date:** [May 31, 2021, 6:43pm UTC](https://community.deeplearning.ai/t/batch-normalization/10589/2 "2021-05-31T18:43:31Z")

</div>

Hi, @bgoyal.

You are trying to normalize each feature independently. From a single example you get a single observation for each feature. So yes, you use whole mini-batches to compute their means and variances during training (and maintain moving averages that are used during inference).

[Here](https://arxiv.org/pdf/1502.03167.pdf) are all the details in case you’re interested 🙂

---

<div class="post-metadata">

**Author:** ![AbhijeetKrishnan](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@AbhijeetKrishnan](https://community.deeplearning.ai/u/AbhijeetKrishnan)\
**Post date:** [May 31, 2021, 6:58pm UTC](https://community.deeplearning.ai/t/batch-normalization/10589/3 "2021-05-31T18:58:23Z")

</div>

Is there a difference between using $\sqrt{\sigma^2 + \epsilon}$ vs. $\sqrt{\sigma^2} + \epsilon$ similar to the Adam optimizer?

---

<div class="post-metadata">

**Author:** ![nramon](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/nramon/32/129097_2.png) [@nramon](https://community.deeplearning.ai/u/nramon)\
**Post date:** [May 31, 2021, 10:29pm UTC](https://community.deeplearning.ai/t/batch-normalization/10589/4 "2021-05-31T22:29:16Z")

</div>

Hi, @AbhijeetKrishnan.

Both avoid divisions by zero, but I don’t know if one of the approaches works best in this particular context. [Consistency](https://github.com/pytorch/pytorch/issues/23796) is definitely important.
