# Dropout before layer normalization

**URL:** <https://discuss.huggingface.co/t/dropout-before-layer-normalization/2829>\
**Category:** 🤗Transformers\
**Created:** [December 15, 2020, 9:43am UTC](https://discuss.huggingface.co/t/dropout-before-layer-normalization/2829 "2020-12-15T09:43:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lifelongeek](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/32.png) [@lifelongeek](https://discuss.huggingface.co/u/lifelongeek)\
**Post date:** [December 15, 2020, 9:43am UTC](https://discuss.huggingface.co/t/dropout-before-layer-normalization/2829/1 "2020-12-15T09:43:52Z")

</div>

At first stage of BartDecoder, we compute

1. compute token embedding
2. add positional embedding
3. layer normalization
4. dropout (optional)

> x = self.embed\_tokens(input\_ids)  
> x += positions  
> x = self.layernorm(x)  
> x = dropout(x, p, self.training)

I am thinking of moving dropout right before adding positional embedding for making token embedding noisy

> x = self.embed\_tokens(input\_ids)  
> x = dropout(x, p, self.training)  
> x += positions  
> x = self.layernorm(x)

Is there any belief that dropout needs to be placed after layer normalization?
