机器学习小数需要规范化吗_机器学习基础规范

机器学习小数需要规范化吗

Norm is defined as a function by which we can measure the magnitude of a vector .Using norm we can measure how “large” a vector is. Norm maps a vector to non-negative value.The norm of a vector x is actually the measurement of the distance of the origin to the point x

范数定义为一个函数,通过它我们可以测量向量的大小。使用范数,我们可以测量向量的“大小”。 范数将向量映射为非负值。向量x的范数实际上是原点到点x的距离的度量

More rigorously, a norm is any func with the following properties:

更严格地说,范数是具有以下属性的任何函数:

  1. Norms are non-negative values.Norms are actually length or distance.So it can not be a negative number.But if a vector is zero, then norm can be zero.

    范数是非负值,范数实际上是长度或距离,因此它不能是负数,但是如果向量为零,则范数可以为零。
  2. Norms respect the triangle inequality.It just means that the norm of the sum of some vectors is less than or equal to the sum of the norms of these vectors: ||x+y||≤||x||+||y||

    范数尊重三角不等式,仅表示某些矢量和的范数小于或等于这些矢量的范数的和: || x + y ||≤ || x || + || y ||

  3. ||a⋅x||=||a||⋅||x||. Here, a is a scalar and x a vector. The norm of a vector multiplied by a scalar is equal to the absolute value of this scalar multiplied by the norm of the vector.

    ||a⋅X || = ||一个||⋅|| X ||。 在此, a是标量, x是向量。 向量乘以标量的范数等于此标量的绝对值乘以向量的范数。

规范的应用 (Application of Norms)

  1. Whenever we need to calculate the loss function, we need to know the magnitude of the distance between the predicated and actual values.

    每当我们需要计算损失函数时,我们都需要知道预测值与实际值之间的距离的大小。
  2. In regularization, we need to know the magnitude of weights.

    在正则化中,我们需要知道权重的大小。
  3. In support-vector machine, we have to find the hyperplane that has the largest perpendicular distance between the hyperplane and the closest samples on either side. Here, we use norm to calculate these distances.

    在支持向量机中,我们必须找到在超平面和任一侧最近的样本之间具有最大垂直距离的超平面。 在这里,我们使用范数来计算这些距离。

关于机器学习,规范可以分类如下: (With respect to machine learning Norms can be classified as follows-)

  1. Lᵖ Norm

    Lᵖ范数
  2. L¹ Norm(Manhattan/Taxicab Distance)

    L¹规范( 曼哈顿/出租车的距离)

  3. The Euclidean Norm(L² norm)

    欧几里德范数(L²范数)
  4. The Max Norm

    最大规范
  5. The Frobenius Norm

    Frobenius范数

Lᵖ范数 (Lᵖ Norm)

Image for post
Formal Definition of Lᵖ Norm
Lᵖ规范的正式定义

For p∈ℝ, p≥1, the p-norm is a norm on suitable real vector spaces given by the pth root of the sum (or integral) of the pth-powers of the absolute values of the vector components.

对于p∈ℝ,p≥1, p-范数是在适当的实矢量空间上的范数该实数空间由矢量分量的绝对值的pth幂之和(或积分)的pth根给出。

Using the following code Lᵖ Norm can be implemented-

使用以下代码LᵖNorm可以实现-

# Import Numpy package and the norm function
import numpy as np
from numpy.linalg import norm
# Define a vector
v = np.array([2,3,1,0])
# Take the q-norm which p=2
p = 2
v_norm = norm(v, ord=p)
# Print values
print('The vector: ', v)
print('The vector norm: ', v_norm)

The output will look like this-

输出看起来像这样-

The vector:  [2 3 1 0]The vector norm:  3.7416573867739413

L¹范数 (L¹ Norm)

Image for post
Formal Definition of L¹ Norm
L¹规范的正式定义

If p=1, we simply have the sum of the absolute values. It is what we have used intuitively at the beginning of this tutorial:

如果p = 1,我们就可以得到绝对值的总和。 这是我们在本教程开始时直观使用的内容:

欧几里德范数(L²范数) (The Euclidean Norm(L² norm))

Image for post

The L² norm is calculated as the square root of the sum of the squared vector values.theL¹ norm is more robust than the L² norm. This means that the L² norm is more sensible to outliers since significant error values will give enormous squared error values.

L²范数被计算为矢量值平方和的平方根。L¹范数比L²范数更健壮。 这意味着L²范数对异常值更敏感,因为显着的误差值将给出巨大的平方误差值。

最大规范 (The max norm)

Image for post
Formal Definition of L¹ Norm
L¹规范的正式定义

L∞ norm corresponds to the absolute value of the greatest element the vector.

大号 ∞范数对应于最大元素的向量的绝对值。

This is the python code of Max Normal-

这是Max Normal的python代码-

# max norm of a vectorfrom numpy import inffrom numpy import arrayfrom numpy.linalg import normv = array([1, 2, 3])print(v)maxnorm = norm(v, inf)print(maxnorm)

Running this code you should get the following output-

运行此代码,您应该获得以下输出:

[1, 2, 3]
3.00

Frobenius范数 (The Frobenius Norm)

Image for post
Formal Definition of Frobenius Norm
Frobenius规范的正式定义

This is equivalent to take the L² norm of the matrix after flattening. L² norm is for vectors while Frobenius is for matrices.

这等效于在展平后采用矩阵的L²范数。 L²范数用于矢量,而Frobenius则用于矩阵。

max norm of a vectorfrom numpy import inffrom numpy import arrayfrom numpy.linalg import normv = array([1, 2, 3])print(v)np.linalg.norm(v)

you should get the following output-

您应该获得以下输出-

8.3666002653407556

谢谢! (Thanks!)

That’s all for today.And don’t forget to share your thoughts with me.

今天就这些了,别忘了与我分享您的想法。

翻译自: https://medium.com/swlh/machine-learning-basics-the-norms-3429ddc66d7c

机器学习小数需要规范化吗

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值