Nuclear norm
A norm is a property of a vector that binds the vector to its quantifiable length. Simply put, we can say that a norm allows us to think of a vector in terms of distance i.e. how long it is.
Norms are highly useful in fields such as physics, engineering, and computational mathematics.
Norms in vector spaces
We can think of a norm as a function that takes an object as input and returns a non-negative scalar value as its output. In the context of vector space, the norm is used to measure the size of a vector.
There is a diverse range of norms that exists in the mathematical world. There are different types of norms because they capture the varying aspects of the mathematical objects being measured. The choice we ultimately take depends on our individual needs and the application at hand.
Let's say we have a two-dimensional space. Then the norm of a
Today we will be discussing a type of norm called nuclear norm in our answer.
Nuclear norms
A nuclear norm of
Before we fully explore nuclear norms, let's understand singular values first. Suppose we have a matrix
The eigenvalues must be sorted in a decreasing order before taking their square roots. These values are crucial to demonstrating the magnitude of a vector.
Note: Singular values always belong to real numbers.
Now that we understand singular values, we can think of the nuclear norm as the function of taking the sum of all these individual values.
It can be mathematically expressed as:
Formula breakdown
denotes the nuclear norm of matrix . denotes the singular value of matrix .
Therefore, the sum of each singular value is added to the nuclear norm variable.
First Python implementation
import numpy as npdef nuclearNorm(matrix):singularVals = np.linalg.svd(matrix, compute_uv = False)nuclearNormVal = np.sum(singularVals)return nuclearNormValmatrix = np.array([[9, 5, 1], [2, 9, 3], [7, 6, 9]])norm = nuclearNorm(matrix)print('The nuclear norm of' , matrix, 'is = ', norm)
Explanation
Line 1: Since we will be storing the values of the matrix in an array, we have to import the
numpylibrary which makes applying operations on arrays faster. The alias name fornumpyis conventionally taken asnp.Line 3: We define a function called
nuclearNormthat takes in a matrix as a parameter and returns its nuclear norm valueLines 4 – 5:
np.linalg.svdis a function in the linear algebra module of numpy that computes singular value decomposition on the values of the matrix. We pass false to thecompute_uvparameter since we do not require the left and right singular matrices. Since the nuclear norm is the sum of the singular values, we will simply callnp.sum(singularVals)to save the value innuclearNormVal.Line 6: We return the calculated
nuclearNormValvalue.Line 8: We define a 3 x 3
matrixwith some starting values and save it in a 2D array.Line 9: We call the
nuclearNormmethod on our matrix and finally print the results.
Second Python implementation
from numpy import linalg as LNGimport numpy as npmatrix = np.array([[9, 5, 1], [2, 9, 3], [7, 6, 9]])print(LNG.norm(matrix, ord = "nuc"))
Explanation
For the sake of simplicity, let's use the same matrix we defined above.
We use the simple norm function provided by the linalg (linear algebra) module and pass a parameter ord the value of nuc.
ordrefers to the order of the norm.value of
nucmeans we want a norm of the order nuclear norm.
Use cases of nuclear norm
Matrix completion
Nuclear norms can be pretty helpful in finding corrupted elements in a partially observed matrix.
Robust Principal Component Analysis
This is a technique that separates a matrix into low-rank and sparse components. We can utilize the nuclear norm here to encourage low ranks and the sparse components can be used to find the outliers in data. For instance, video surveillance and image denoising.
Graph analysis
Nuclear norm regularization is a technique that is used in graph analysis problems. We can solve problems like graph completion and link prediction as well as finding missing links.
Why is a norm always greater or equal to 0?
Free Resources