(self, x)
| 281 | self.variance_epsilon = eps |
| 282 | |
| 283 | def forward(self, x): |
| 284 | u = x.mean(-1, keepdim=True) |
| 285 | s = (x - u).pow(2).mean(-1, keepdim=True) |
| 286 | x = (x - u) / torch.sqrt(s + self.variance_epsilon) |
| 287 | return self.weight * x + self.bias |
| 288 | |
| 289 | |
| 290 | class BertSelfAttention(nn.Module): |