phlower.nn.LayerNorm

class phlower.nn.LayerNorm(nodes, eps=1e-05, elementwise_affine=True, bias=True)[source]

Bases: IPhlowerCoreModule, Module

LayerNorm is a neural network module that applies Layer Normalization on the input tensor.

Parameters:
  • nodes (list[int]) – List of feature dimension sizes (The last value of tensor shape).

  • eps (float) – A value added to the denominator for numerical stability.

  • elementwise_affine (bool) – Whether to learn additional affine parameters.

  • bias (bool) – Whether to learn an additive bias if elementwise_affine is True.

Examples

>>> layer_norm = LayerNorm()
>>> layer_norm(data)

Methods

forward(data, *[, field_data])

forward function which overloads torch.nn.Module

from_setting(setting)

Generate LayerNorm from setting object

get_nn_name()

Return neural network name

Attributes

T_destination

call_super_init

dump_patches

training

forward(data, *, field_data=None, **kwards)[source]

forward function which overloads torch.nn.Module

Parameters:
  • data (IPhlowerTensorCollections) – IPhlowerTensorCollections data which receives from predecessors

  • field_data (ISimulationField | None) – ISimulationField | None Constant information through training or prediction

Returns:

Tensor object

Return type:

PhlowerTensor

classmethod from_setting(setting)[source]

Generate LayerNorm from setting object

Parameters:

setting (LayerNormSetting) – setting object

Returns:

LayerNorm object

Return type:

Self

classmethod get_nn_name()[source]

Return neural network name

Returns:

name

Return type:

str