L2 norm
The L2 norm of a vector is its Euclidean length, calculated as the square root of the sum of the squares of its components.
Grokking Machine Learning
The L2 norm of a vector is the square root of the sum of the squared values of its components.
- How it is used
- Uses squared model coefficients as a complexity measure in regularization to help reduce overfitting.
- How deep it goes
- Defines the complexity measure, explains coefficient shrinkage, and excludes model bias from the calculation.
- Examples
- Uses movie recommendation coefficients and a polynomial regression exercise to illustrate complexity and ridge error.
- What you can do after
- Apply L2 regularization by adding a coefficient-complexity measure to regression error during training.
Natural Language Processing in Action, Second Edition
The L2 norm of a vector is the square root of the sum of the squares of its components.
- How it is used
- Supports measuring vector length, Euclidean distance, normalization, and cosine-based comparison in NLP vector spaces.
- How deep it goes
- Defines the formula, explains geometric consequences, and demonstrates NumPy normalization without deriving deeper linear-algebra theory.
- Examples
- Uses two-dimensional vector geometry, a four-element NumPy vector, TF vectors, and normalized sentence embeddings.
- What you can do after
- Apply it via NumPy to calculate vector lengths, normalize embeddings, and support cosine-similarity computations.
Read how Natural Language Processing in Action, Second Edition explains l2 norm →
Grokking Machine Learning, Second Edition
The L2 norm of a vector is its Euclidean length, computed as the square root of the sum of squared components.
- How it is used
- Balances regression accuracy against model complexity when regularizing models to reduce overfitting.
- How deep it goes
- Defines L2 norm through squared coefficients, excludes bias, and illustrates coefficient shrinkage without formal mathematics.
- Examples
- Works through two regression models’ squared-coefficient totals and assigns a ridge-error calculation exercise.
- What you can do after
- Apply it to calculate a ridge regression complexity term and favor small, nonzero coefficients with few features.
Read how Grokking Machine Learning, Second Edition explains l2 norm →
Rearchitecting LLMs
The L2 norm is the square root of the sum of squared vector components, measuring vector magnitude with greater emphasis on large components.
- How it is used
- Uses activation intensity as dynamic importance when selecting neurons for width pruning.
- How deep it goes
- Defines the square-root-of-squared-components calculation and reduces batch and sequence dimensions to per-neuron scores.
- Examples
- Compares alternating positive and negative activations with a single activation spike and evenly spread values.
- What you can do after
- Apply PyTorch activation norms to score MLP neurons by observed usage during calibration for width pruning.
Math for Web Design
Magnitude is the scalar length or size of a vector, representing the straight-line distance it covers.
- How it is used
- Measures the length of a movement vector for element positioning and consistent-speed movement.
- How deep it goes
- Defines magnitude with a 2D formula and implements it in JavaScript, including its use in normalization.
- Examples
- Uses a Vector2 class with magnitude(), normalize(), and a CSS translation method.
- What you can do after
- Apply it via JavaScript to measure a 2D offset and normalize it for directional movement.
Math and Architectures of Deep Learning
The Euclidean norm measuring a vector's length by squaring components, summing them, and taking the square root.
- How it is used
- Measures vector magnitude, model prediction error, and weight size used for regularization.
- How deep it goes
- Defines the formula, dot-product relationship, geometric meaning, normalization use, and regularization role without deriving matrix norms.
- Examples
- Uses error vectors across training data, right-triangle geometry, unit-vector normalization, and weight penalties.
- What you can do after
- Evaluate vector magnitude, interpret prediction error, normalize vectors, and understand L2 weight regularization.
Read how Math and Architectures of Deep Learning explains l2 norm →
LLM Evaluation and Alignment, The Foundational Ideas
The L2 norm is the Euclidean length of a vector, calculated as the square root of the sum of the squares of its components.
- How it is used
- Defines vector magnitude before contrasting Euclidean distance with cosine similarity for embedding-based semantic evaluation.
- How deep it goes
- Defines the square-root-of-squared-components calculation and explains why magnitude can mislead in high-dimensional embeddings.
- Examples
- Uses weather-related sentences and geometric vectors with different lengths but similar directions.
- What you can do after
- Evaluate when vector magnitude may distort semantic comparisons and understand why cosine similarity can be preferred.
Read how LLM Evaluation and Alignment, The Foundational Ideas explains l2 norm →
Also covered in
- Building Quantum Software with Python
- Building Specialized AI SystemsIn early access (MEAP)
- Inside Deep Learning: Math, Algorithms, Models
- Deep Learning with R, Third Edition
What to know first
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- embeddingAn embedding is a numerical vector representation of an item in a feature space, encoding selected properties or relationships for computational tasks such as comparison or retrieval.
- inner productAn inner product is a scalar-valued operation on two vectors that generalizes the dot product, which for real coordinate vectors is the sum of products of corresponding components.
- language modelA language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
Related concepts
- Euclidean distanceequivalent to · Euclidean distance is the straight-line distance between two points, calculated as the square root of the sum of squared differences between corresponding coordinates.
- L1 regularizationused by · L1 regularization is a technique that adds a penalty proportional to the sum of absolute model-parameter values, encouraging sparse parameter estimates.
- weight decayused by · A regularization technique that reduces model parameter magnitudes during optimization, either by adding a penalty to the objective or by directly shrinking parameters.
- activationmeasures · An activation is a numerical value or tensor produced by a neural-network unit, layer, or operation during a forward computation.
- probability theoryproduces · Probability theory is the mathematical framework for quantifying and reasoning about uncertainty in events, variables, and outcomes.
Questions about l2 norm
What is l2 norm?
The L2 norm of a vector is its Euclidean length, calculated as the square root of the sum of the squares of its components.
Which Manning books explain l2 norm?
Grokking Machine Learning, Natural Language Processing in Action, Second Edition, Grokking Machine Learning, Second Edition, Rearchitecting LLMs, Math for Web Design, Math and Architectures of Deep Learning and LLM Evaluation and Alignment, The Foundational Ideas.
What should I know before learning l2 norm?
Manning books that teach l2 norm usually introduce array, embedding, inner product and language model first.
What is l2 norm also called?
L2 norm is also called magnitude, Euclidean norm or 2-norm.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.






