Vector Norms

L 1 L_1 L1 Norm (Taxicab Norm or Manhattan norm) L 2 L_2 L2 Norm (Euclidean norm)Max Norm
The L 1 L_1 L1 norm is calculated as the sum of the absolute vector values.The L 2 L_2 L2 norm is calculated as the square root of the sum of the squared vector values.The max norm is calculated as returning the maximum value of the vector, hence the name.
∥ v ∥ 1 = ∣ a 1 ∣ + ∣ a 2 ∣ + ∣ a 3 ∣ \begin{Vmatrix} \boldsymbol{v} \end{Vmatrix}_1 = \begin{vmatrix} a_1 \end{vmatrix} + \begin{vmatrix} a_2 \end{vmatrix} + \begin{vmatrix} a_3 \end{vmatrix} v1=a1+a2+a3 ∥ v ∥ 2 = ∑ i = 1 3 a i 2 = a 1 2 + a 2 2 + a 3 2 \begin{Vmatrix} \boldsymbol{v} \end{Vmatrix}_2 = \sqrt{\sum\limits_{i=1}^3{a_i^2}} = \sqrt{a_1^2 + a_2^2 + a_3^2} v2=i=13ai2 =a12+a22+a32 ∥ v ∥ ∞ = max ⁡ ( a 1 , a 2 , a 3 ) \begin{Vmatrix} \boldsymbol{v} \end{Vmatrix}_{\infty} = \max(a_1, a_2, a_3) v=max(a1,a2,a3)
In effect, the L 1 L_1 L1 norm is a calculation of the Manhattan distance from the origin of the vector space.The L2 norm is also known as the Euclidean norm as it is calculated as the Euclidean distance from the origin.
The L 1 L_1 L1 norm is often used when fitting machine learning algorithms as a regularization method, e.g. a method to keep the coefficients of the model small, and in turn, the model less complex.Like the L 1 L_1 L1 norm, the L 2 L_2 L2 norm is often used when fitting machine learning algorithms as a regularization method, e.g. a method to keep the coefficients of the model small and, in turn, the model less complex.Max norm is also used as a regularization in machine learning, such as on neural network weights, called max norm regularization.
By far, the L 2 L_2 L2 norm is more commonly used than other vector norms in machine learning.

L 1 L_1 L1 norm

  • The L 1 L_1 L1 norm of a vector can be calculated in NumPy using the norm() function with a parameter to specify the norm order, in this case 1.
# l1 norm of a vector
from numpy import array
from numpy.linalg import norm
a = array([1, 2, 3])
print(a) # [1 2 3]
l1 = norm(a, 1)
print(l1) # 6

L 2 L_2 L2 Norm

  • The L 2 L_2 L2 norm of a vector can be calculated in NumPy using the norm() function with default parameters.
# l2 norm of a vector
from numpy import array
from numpy.linalg import norm
a = array([1, 2, 3])
print(a) # [1 2 3]
l2 = norm(a)
print(l2) # 3.7416573867739413

Max Norm

The max norm of a vector can be calculated in NumPy using the norm() function with the order parameter set to inf.

# max norm of a vector
from numpy import inf
from numpy import array
from numpy.linalg import norm
a = array([1, 2, 3])
print(a) # [1 2 3]
maxnorm = norm(a, inf)
print(maxnorm) # 3.0
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值