Skip to content
Glacius
Linear algebraConcept reference

Frobenius norm

The Frobenius norm is the square root of the sum of squared real matrix entries.

On this page 10 sections
  1. Overview
  2. Turn a matrix of errors into one size
  3. Compute the norm entry by entry
  4. Keep the norm and its square distinct
  5. Measure the difference between two matrices
  6. Read a matrix loss
  7. Key takeaway
  8. Further questions
  9. Sources & further reading
  10. Concept connections

01Turn a matrix of errors into one size#

A model can make several predictions for each example in a batch. Subtract the targets and you get a matrix of errors. To compare two predictions, we often need one number that measures the size of that whole matrix.

Simply adding the entries would let positive and negative errors cancel. A residual of −4-4 is still an error of size four. The Frobenius norm counts every entry by squaring it before adding.

Start with a familiar vector. The length of (3,−4)(3,-4) is 32+(−4)2=5\sqrt{3^2+(-4)^2}=5. The Frobenius norm uses the same operation on all the coordinates of a matrix.

You can imagine laying the entries out in one long vector. Their arrangement into rows and columns does not change this length. We are measuring entry sizes, rather than how the matrix transforms a vector.

02Compute the norm entry by entry#

Consider this matrix. There are four entries to include, including the negative one.

A=(1−224)A=\begin{pmatrix}1&-2\\2&4\end{pmatrix}

The first row contributes 12+(−2)2=51^2+(-2)^2=5. The second contributes 22+42=202^2+4^2=20. Add those contributions, then take the square root: 25=5\sqrt{25}=5.

Matrix rows (1,-2);(2,4) become squared entries (1,4);(4,16). Their sum is 25 and the Frobenius norm is 5.Matrix rows (1,-2);(2,4) become squared entries (1,4);(4,16). Their sum is 25 and the Frobenius norm is 5.
Figure 1Matrix rows (1,-2);(2,4) become squared entries (1,4);(4,16). Their sum is 25 and the Frobenius norm is 5.
Link to this figure ↗Download SVGDownload PNG

For a matrix with mm rows and nn columns, the definition is

∥A∥F=∑i=1m∑j=1nAij 2.\|A\|_F=\sqrt{\sum_{i=1}^{m}\sum_{j=1}^{n}A_{ij}^{\,2}}.

Here AijA_{ij} means the entry in row ii, column jj. The two sums visit every column in every row. The double bars mean a norm, and the subscript FF specifies the Frobenius norm. The result is one nonnegative number.

Check your reasoning

Matrix rows (2,−4)(2,-4); (4,0)(4,0). Give its Frobenius norm.

Show answer and explanation
6

Squared entries total 3636; norm 66.

03Keep the norm and its square distinct#

Our example has two useful quantities: ∥A∥F=5\|A\|_F=5 and ∥A∥F2=25\|A\|_F^2=25. The squared norm is just the sum of squared entries. Taking a square root when a formula asks for the squared norm changes the quantity.

If the entries measure errors in meters, the norm has units of meters; the squared norm has units of square meters. The outer exponent in ∥A∥F2\|A\|_F^2 matters.

For entries 33 and −4-4, adding absolute values gives 77, while the square-root-of-squares calculation gives 55. These are different ways to measure size.

Also include entries away from the diagonal. The Frobenius norm is not a determinant, a trace, or the square of a matrix product. Its definition is an entry-by-entry calculation.

Check your reasoning

Matrix rows (0,3)(0,3); (4,0)(4,0). Claimed Frobenius norm 77. Repair.

  1. A7
  2. B5
  3. C25
Show answer and explanation
5

Squared entries total 2525; norm 55.

Nothing in the definition requires a square matrix. For the rectangular matrix below, the zero entries contribute zero, and all six positions are included.

B=(1−2020−4)B=\begin{pmatrix}1&-2&0\\2&0&-4\end{pmatrix}

The squared entries total 1+4+0+4+0+16=251+4+0+4+0+16=25, so ∥B∥F=5\|B\|_F=5. Different matrices can have the same norm; the single size does not identify the individual entries.

04Measure the difference between two matrices#

To measure the distance between two equally shaped matrices, first subtract corresponding entries. For example,

A=(4213)B=(121−1)\begin{gathered}A=\begin{pmatrix}4&2\\1&3\end{pmatrix}\\ B=\begin{pmatrix}1&2\\1&-1\end{pmatrix}\end{gathered}

Subtracting corresponding entries gives

A−B=(3004).A-B=\begin{pmatrix}3&0\\0&4\end{pmatrix}.

The distance is ∥A−B∥F=32+42=5\|A-B\|_F=\sqrt{3^2+4^2}=5. Entries where the matrices agree contribute nothing.

The order of operations matters: form the residual matrix, then measure it. In general, ∥A−B∥F\|A-B\|_F is not ∥A∥F−∥B∥F\|A\|_F-\|B\|_F.

For instance, matrices containing the single entries 33 and −3-3 each have norm 33. Their norms differ by zero, but their entries differ by 66. Measuring each matrix separately loses the information needed for distance.

Check your reasoning

Rows AA: (4,2)(4,2); (1,5)(1,5). Rows BB: (2,1)(2,1); (1,3)(1,3). Give ∥A−B∥F\|A-B\|_F.

Show answer and explanation
3

Residual rows (2,1)(2,1); (0,2)(0,2); norm 33.

05Read a matrix loss#

In a prediction problem, write R=Y^−YR=\widehat Y-Y for the residual matrix. A commonly chosen loss is

L=12m∥R∥F2.L=\frac{1}{2m}\|R\|_F^2.

Read this in stages: square every residual, add the squares, then divide by 2m2m. Here mm is the number of examples. The norm notation itself does not perform any averaging.

For two examples with two outputs each, suppose all four residuals equal 11. The squared Frobenius norm is 44, and this loss is 4/(2⋅2)=14/(2\cdot2)=1.

This choice averages the summed output errors over examples, with an extra factor of one half. Averaging over every entry would use a different divisor. Always read the normalization around the norm, as well as the norm itself.

This size treats entries equally in their current units. If one output is measured in thousands and another in fractions, their squared contributions may be very different. Choosing units or weights is part of designing a loss; the Frobenius norm tells you exactly what the chosen formula counts.

Key takeaway

Square every entry, add all the squares, and take the nonnegative square root. For an error norm, subtract the matrices first.

  • Compute a matrix's Frobenius norm.

Further questions

Can an SVD give approximation error without rebuilding every entry?
Yes. For a leading-component truncation, the Frobenius error is the square root of the sum of discarded singular-value squares.

Sources & further reading

  1. [1]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Frobenius norm.” Math behind ML. /learn/la-frobenius