MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / __init__

Method __init__

python/oneflow/nn/modules/normalization.py:313–331  ·  view source on GitHub ↗
(
        self,
        normalized_shape: _shape_t,
        eps: float = 1e-05,
        elementwise_affine: bool = True,
    )

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 6

reset_parametersMethod · 0.95
tupleClass · 0.85
ParameterMethod · 0.80
__init__Method · 0.45
TensorMethod · 0.45
register_parameterMethod · 0.45

Tested by

no test coverage detected