Read the equation
The implementation subtracts the vector’s mean, divides by √(population variance+EPSILON_PHI), then applies scalar gain γ and offset β. This controls the scale of a feature vector while preserving relative centered differences. The code uses one gain and one offset for the whole vector rather than separately learned values per component.
Terms & definitions
| Term | Meaning in this source |
|---|---|
| x | Feature vector |
| mu | Component mean |
| sigma | Regularized component standard deviation |
| gamma | Scalar gain |
| beta | Scalar offset |
How it works
Read the definition from its right-hand expression to the quantity on the left. Its surrounding source records the intended input, state, or parameter context. Where the source leaves an operation unspecified, this page preserves that gap.
Assumptions & limits
Source recovery establishes that the expression appears in this record. Its mathematical validity, implementation behavior, and interpretation must be assessed separately. See the linked source and research notes for the checks available for this version.
Original context
Read the surrounding source passage
}
}
return output
}
// LayerNorm computes layer normalization
// y = (x - μ) / σ · γ + β
func LayerNorm(x []float64, gamma, beta float64) []float64 {
n := len(x)
if n == 0 {
return x
}
// Compute mean
mean := 0.0
for _, v := range x {
mean += vExact original notation
y = (x - μ) / σ · γ + β