Initialize the RMSNorm normalization layer. Args: dim (int): The dimension of the input tensor. eps (float, optional): A small value added to the denominator for numerical stability. Default is 1e-6. Attributes: e
(self, dim: int, eps: float = 1e-6)
| 9 | |
| 10 | class RMSNorm(torch.nn.Module): |
| 11 | def __init__(self, dim: int, eps: float = 1e-6): |
| 12 | """ |
| 13 | Initialize the RMSNorm normalization layer. |
| 14 | |
| 15 | Args: |
| 16 | dim (int): The dimension of the input tensor. |
| 17 | eps (float, optional): A small value added to the denominator for numerical stability. Default is 1e-6. |
| 18 | |
| 19 | Attributes: |
| 20 | eps (float): A small value added to the denominator for numerical stability. |
| 21 | weight (nn.Parameter): Learnable scaling parameter. |
| 22 | |
| 23 | """ |
| 24 | super().__init__() |
| 25 | self.eps = eps |
| 26 | self.weight = nn.Parameter(torch.ones(dim)) |
| 27 | |
| 28 | def _norm(self, x): |
| 29 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected