---
title: LayerNorm
description: "对单个样本的所有特征进行归一化。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/KunpengHPCKit_developer_199.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/KunpengHPCKit_developer_199.html
indexId: 3ee911acca9fba9c93b22ea5900288dce6678d42555d7e3e4a7b0f8e34978e2c67
---
# LayerNorm

#### 接口功能

对单个样本的所有特征进行归一化。


#### 函数原型

```
torch.nn.LayerNorm(
normalized_shape: Union[int, List[int], torch.Size],
eps: float = 1e-5,
elementwise_affine: bool = True,
device=None,
dtype=None
)
```


#### 参数说明


**表1 参数说明**

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| normalized\_shape | int/list/tuple | 是 | 需归一化的维度（如 [C, H, W]或hidden\_size）。 |
| eps | float | 否 | 数值稳定性常数（默认1e\-5）。 |
| elementwise\_affine | bool | 否 | 是否逐元素学习γ和β（默认True）。 |
