Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Layer Normalization in Pytorch without learnable parameters?

We can add layer normalization in Pytorch by doing: torch.nn.LayerNorm(shape). However, this is layer normalization with learnable parameters. I.e, it's the following equation:

enter image description here

Does Pytorch have builtin layer normalization without learnable parameters?

like image 913
Roymunson Avatar asked Aug 04 '26 10:08

Roymunson


1 Answers

You can use nn.LayerNorm, setting the elementwise flag to False. This way the layer won't have learnt parameters. See source code for additional reference.

like image 158
Ivan Avatar answered Aug 07 '26 00:08

Ivan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!