Training, adaptation, compression, and systems techniques · Training, fine-tuning, adaptation, compression, and systems techniques · TRN008 · Training method
Layer normalization
Normalizes a specified set of features within each example/token, avoiding minibatch-moment dependence.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page. The methods that run it are Experimental.
- FT-Transformer Experimental
Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.
- Availability
- Runs in CodeSplash (Experimental)
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through learn.ft_transformer. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Normalizes a specified set of features within each example/token, avoiding minibatch-moment dependence.
Question / hypotheses
Does this intervention improve the intended quality, adaptation, resource, or reliability objective under a controlled comparison? It defines a method, not an intrinsic null-hypothesis test.
Architecture / computational structure
Within-token feature statistics feed learned affine gains and offsets; pre-norm and post-norm transformer placement differ.
Assumptions
Normalize exactly the intended axes. Masking, residual placement, precision, and epsilon affect stability; it is not interchangeable with batch normalization.
Formula / computational definition
Parameters and notation
Learned: feature gains and biases. Hyperparameters: normalized shape, epsilon, placement, affine option. No running batch moments are necessary in ordinary LayerNorm.
Fitting, fine-tuning, and adaptation
When adapting a pretrained model, preserve its normalization placement and epsilon unless deliberately studying an architectural change. Affine-only tuning is possible but must be evaluated against full/PEFT alternatives.
How to use and calibrate
Inspect activation and gradient scale, especially in mixed precision. Example: stabilize hidden states in a text or audio transformer.
Example application
stabilize hidden states in a text or audio transformer.
Interpretation / pitfalls
Watch out
Replacing normalization changes the checkpoint’s function. Different reduction axes can silently produce plausible shapes with incorrect semantics.
Python and R code examples
Scope: numerical mechanism demonstration. Validation: Python executed successfully on the supplied synthetic inputs; R reviewed but not executed (Rscript unavailable).
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — numerical mechanism demonstration. · needs numpy
import numpy as np
X=np.array([[1.,2.,4.],[2.,3.,8.]])
print((X-X.mean(1,keepdims=True))/np.sqrt(X.var(1,keepdims=True)+1e-5))
Component demo, not a trained model — numerical mechanism demonstration.
X <- rbind(c(1,2,4),c(2,3,8)); Z <- X-rowMeans(X)
print(Z/sqrt(rowMeans(Z^2)+1e-5))
Sources
- Primary/official source 1arxiv.org
From the CodeSplash reference, entry TRN008.