Skip to content

Commit

Permalink
Correct LayerNormalization
Browse files Browse the repository at this point in the history
  • Loading branch information
zjz17 committed Jul 15, 2017
1 parent ca8c7c0 commit b40c2da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions transformer/Modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def forward(self, z):
if z.size(1) == 1:
return z

mu = torch.mean(z, dim=1)
sigma = torch.std(z, dim=1)
mu = torch.mean(z, dim=-1)
sigma = torch.std(z, dim=-1)
ln_out = (z - mu.expand_as(z)) / (sigma.expand_as(z) + self.eps)
ln_out = ln_out * self.a_2.expand_as(ln_out) + self.b_2.expand_as(ln_out)

Expand Down

0 comments on commit b40c2da

Please sign in to comment.