(x: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor, eps: float = 1e-6)
| 145 | |
| 146 | |
| 147 | def layer_norm_2d(x: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor, eps: float = 1e-6) -> torch.Tensor: |
| 148 | u = x.mean(1, keepdim=True) |
| 149 | s = (x - u).pow(2).mean(1, keepdim=True) |
| 150 | x = (x - u) / torch.sqrt(s + eps) |
| 151 | return weight[:, None, None] * x + bias[:, None, None] |
| 152 | |
| 153 | |
| 154 | def sinusoidal_pe(h: int, w: int, d_model: int) -> torch.Tensor: |
no outgoing calls
no test coverage detected