(
self,
normalized_shape: _shape_t,
eps: float = 1e-05,
elementwise_affine: bool = True,
)
| 311 | elementwise_affine: bool |
| 312 | |
| 313 | def __init__( |
| 314 | self, |
| 315 | normalized_shape: _shape_t, |
| 316 | eps: float = 1e-05, |
| 317 | elementwise_affine: bool = True, |
| 318 | ) -> None: |
| 319 | super(LayerNorm, self).__init__() |
| 320 | if isinstance(normalized_shape, int): |
| 321 | normalized_shape = (normalized_shape,) |
| 322 | self.normalized_shape = tuple(normalized_shape) |
| 323 | self.eps = eps |
| 324 | self.elementwise_affine = elementwise_affine |
| 325 | if self.elementwise_affine: |
| 326 | self.weight = flow.nn.Parameter(flow.Tensor(*self.normalized_shape)) |
| 327 | self.bias = flow.nn.Parameter(flow.Tensor(*self.normalized_shape)) |
| 328 | else: |
| 329 | self.register_parameter("weight", None) |
| 330 | self.register_parameter("bias", None) |
| 331 | self.reset_parameters() |
| 332 | |
| 333 | def reset_parameters(self) -> None: |
| 334 | if self.elementwise_affine: |
nothing calls this directly
no test coverage detected