# Using batchnorm in FC layers

**URL:** <https://discuss.pytorch.org/t/using-batchnorm-in-fc-layers/18393>\
**Category:** Uncategorized\
**Created:** [May 20, 2018, 7:11pm UTC](https://discuss.pytorch.org/t/using-batchnorm-in-fc-layers/18393 "2018-05-20T19:11:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarthak268](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@sarthak268](https://discuss.pytorch.org/u/sarthak268)\
**Post date:** [May 20, 2018, 7:11pm UTC](https://discuss.pytorch.org/t/using-batchnorm-in-fc-layers/18393/1 "2018-05-20T19:11:17Z")

</div>

Could you please guide me on how to use batchnorm with FC layers as in my case it gives the same output value for different inputs?

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [May 22, 2018, 11:00am UTC](https://discuss.pytorch.org/t/using-batchnorm-in-fc-layers/18393/2 "2018-05-22T11:00:11Z")

</div>

If you add a `BatchNorm` layer into your model, your output will always be the same, even if you use different inputs?  
Could you provide a small working example?  
In general, you just have to add a `BatchNorm` layer between your linear layers:

```auto
model = nn.Sequential(
    nn.Linear(10, 20),
    nn.BatchNorm1d(20),
    nn.Linear(20, 2)
)

batch_size = 20
x = torch.randn(batch_size, 10)
output = model(x)
print(output)

```

---

<div class="post-metadata">

**Author:** ![sarthak268](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@sarthak268](https://discuss.pytorch.org/u/sarthak268)\
**Post date:** [May 23, 2018, 8:49pm UTC](https://discuss.pytorch.org/t/using-batchnorm-in-fc-layers/18393/3 "2018-05-23T20:49:53Z")

</div>

Found my mistake, anyways thanks for your effort.
