线性代数 范数

In the Linear Algebra Series, to give you a quick recap, we’ve learned what are vectors, matrices & tensors, how to calculate dot product to solve systems of linear equations, and what are identity and inverse matrices.

在“ 线性代数系列”中 ,为了让您快速回顾一下,我们了解了什么是向量,矩阵和张量 , 如何计算点积以求解线性方程组 ,以及什么是恒等式和逆矩阵。

Continuing the series, the next very important topic is Vector Norms.

继系列之后,下一个非常重要的主题是矢量规范。

So,

所以,

什么是向量规范? (What are Vector Norms?)

Vector Norms are any functions that map a vector to a positive value which is the magnitude of the vector or the length of the vector. Now, there are different functions that offer us different ways to calculate vector lengths.

向量范数是将向量映射到正值的任何函数,该正值是向量的大小或向量的长度。 现在,有不同的函数为我们提供了计算向量长度的不同方法。

That’s okay but why are we studying this and what does this vector length represent…?

没关系,但是为什么我们要研究这个,这个向量长度代表什么呢?

为什么要了解规范? (Why learn about Norms??)

Norms are a very important concept in machine learning and deep learning that is generally used to calculate the error in the predictions of an ML/DL model.

规范是机器学习和深度学习中一个非常重要的概念,通常用于计算ML / DL模型的预测误差。

The length of the vector usually represents the error between the prediction and the actual observation(label).

向量的长度通常表示预测值与实际观测值(标签)之间的误差。

We often need to calculate the length or magnitude of vectors to be either used directly as a regularization method in ML or as part of broader vector or matrix operations.

我们经常需要计算向量的长度或大小,以直接用作ML中的正则化方法或作为更广泛的向量或矩阵运算的一部分。

So, what sort of functions are these?

那么,这些是什么样的功能呢?

规范函数的特征 (Characteristics of Norm functions)

Norms are any functions that are characterized by the following properties:

规范是具有以下特性的任何函数:

  1. Norms return non-negative values because it’s the magnitude or length of a vector which can’t be negative.范式返回非负值,因为它是矢量的大小或长度不能为负。
  2. Norms are 0 if and only if the vector is a zero vector.当且仅当向量为零向量时,范数为0。
  3. Norms follow the triangle inequality i.e. the norm of the sum of two(or more) vectors is less than or equal to the sum of the norms the individual vectors. It simply states that geometrically, the shortest path between any two points is a line.

    范数遵循三角形不等式,即两个(或多个)矢量之和的范数小于或等于各个矢量的范数的总和。 它只是简单地指出,在几何上,任意两点之间的最短路径是一条线。

    Represented by the equation:

    由等式表示:

    ∥a+b∥≤∥a∥+∥b∥

    ∥a+b∥≤∥a∥+∥b∥

    where a and b are two vectors and the vertical bars ∥ generally denote the norm.

    其中a和b是两个向量,竖线∥通常表示范数。

  4. 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.

    向量乘以标量的范数等于此标量的绝对值乘以向量的范数。

    Representing equation: ∥k⋅

    表示方程式:∥k⋅

    x∥=|k|⋅∥x

    X∥= | K |⋅∥X∥

计算P范数的步骤 (Steps to calculate P-norms)

The calculation of a P-norm is based on the central formula:

P范数的计算基于以下中央公式:

x=(∑ᵢ|xᵢ|ᵖ)¹/ᵖ

∥X∥ₚ=(Σᵢ| Xᵢ|ᵖ)¹/ᵖ

Here is a quick 4-step process to get the p-norm of a vector

这是获取向量p范数的快速四步过程

  1. Get the absolute value of each element of the vector.获取向量中每个元素的绝对值。
  2. Raise these absolute values to a power p.

    将这些绝对值提高到幂p。

  3. Calculate the sum of all these raised absolute values.计算所有这些提高的绝对值的总和。
  4. Get the pₜₕ root or raise the power to 1/p on the result of the previous step.

    得到该pₜₕ根或提高功率到1 / P上一步骤的结果。

Now, based on the value of P in the formula, we get different types of Norms. Let’s discuss these one-by-one:

现在,基于公式中P的值我们得到了不同类型的范数。 让我们一一讨论:

L⁰范数 (L⁰ Norm)

Putting p = 0 in the formula will get us the L⁰ norm.

p = 0放在公式中将得到L⁰范数。

Anything raised to the power 0 will return 1 except 0. L⁰ is not really a norm because it doesn’t exhibit characteristic #4(described above). Multiplying a constant will give us that number itself.

升到0的所有幂都将返回1(除0之外)。L⁰不是真正的范数,因为它没有表现出特征4 (如上所述)。 乘以一个常数将给我们这个数字本身。

L¹范数 (L¹ Norm)

Putting p = 1 gets us L¹ norm. Essentially, the formula would be calculating the sum of the absolute values of the vector.

p = 1可以得到L¹范数。 本质上,该公式将计算向量的绝对值之和。

Formula: |x|₁=(∑ᵢ |xᵢ|)

公式:| x |₁=(∑ᵢ |xᵢ|)

This is used to calculate the Mean Absolute Error.

这用于计算平均绝对误差。

Python代码 (Python Code)

We can get the L¹ norm using the linear algebra module of the Numpy package which offers a norm() method. By default, the norm function is set to calculate the L2 norm but we can pass the value of p as the argument. So, for L¹ norm, we’ll pass 1 to it:

我们可以使用提供了norm()方法的Numpy包的线性代数模块来获得L¹范数。 默认情况下,范数函数设置为计算L2范数,但是我们可以将p的值作为参数传递。 因此,对于L¹范数,我们将1传递给它:

from numpy import linalg#creating a vectora = np.array([1,2,3])#calculating L¹ normlinalg.norm(a, 1)##output: 6.0

L²规范 (L² Norm)

Putting p = 2 gets us L² norm. The formula would be calculating the square root of the sum of the squares of the values of the vector.

p = 2得到L²范数。 该公式将计算向量值的平方和的平方根。

Also known as the Euclidean norm. This is a widely used norm in Machine learning which is used to calculate the root mean squared error.

也称为欧几里得范数。 这是机器学习中广泛使用的规范,用于计算均方根误差。

∥x∥₂ = (∑ᵢ xᵢ²)¹/²

∥x∥²=(∑ᵢxᵢ²)¹/²

So, for a vector u, L² Norm would become:

因此,对于向量u, L²范数将变为:

Python代码 (Python Code)

Again, using the same norm function, we can calculate the L² Norm:

同样,使用相同的范数函数,我们可以计算L²范数:

norm(a) # or you can pass 2 like this: norm(a,2)## output: 3.7416573867739413

L²平方的平方 (Squared L² Norm)

∑ᵢ|xᵢ|²

∑ᵢ |xᵢ|²

The squared L2 norm is simply the L2 norm but without the square root. Squaring the L2 norm calculated above will give us the L2 norm.

平方L2范数就是L2范数,但没有平方根。 对以上计算的L2范数求平方将得到L2范数。

It is convenient because it removes the square root and we end up with the simple sum of every squared value of the vector.

这样做很方便,因为它去除了平方根,最后得到了向量每个平方值的简单和。

The squared Euclidean norm is widely used in machine learning partly because it can be calculated with the vector operation xx.

平方欧几里得范被广泛应用于机械部分的学习,因为它可以用向量运算xᵀX来计算

Python代码 (Python Code)

Let’s verify this in python code:

让我们在python代码中验证一下:

x = np.array([[1], [3], [5], [7]])euclideanNorm = x.T.dot(x)## output: array([[84]])np.linalg.norm(x)**2##ouput: 84.0

最大规范 (The Max Norm)

This is the L∞ norm which simply returns the absolute value of the greatest element of the vector.

这是L∞范数,它仅返回向量最大元素的绝对值。

Formula becomes:

公式变为:

‖x‖∞=maxᵢ|xᵢ|

‖x‖∞=maxᵢ|xᵢ|

Python代码 (Python Code)

Let’s verify this in python code, we’ll simply need to pass infinity to the norm function:

让我们在python代码中进行验证,我们只需要将infinity传递给norm函数即可:

x = np.array([[1], [3], [5], [7]])norm(x, np.inf)##output: 7.0

You can play around with all the python codes here:

您可以在这里使用所有的python代码:

图形可视化 (Graphical Visualisations)

Let’s try to analyze the plots graphically. I’ve used the same formula in 2 dimensions(x,y) and the 3rd dimension represents the norm itself.

让我们尝试以图形方式分析图。 我在2维(x,y)中使用了相同的公式,第3维代表标准本身。

You can check out this surface plotter which I used to get these plots.

您可以检查一下我用来获取这些绘图的表面绘图仪 。

L¹范数 (L¹ Norm)

https://academo.org/demos/3d-surface-plotter/https://academo.org/demos/3d-surface-plotter/创建

More like planes attached to each other. X and Y are the parameters here.

更像飞机相互依附。 X和Y是此处的参数。

L²规范 (L² Norm)

https://academo.org/demos/3d-surface-plotter/https://academo.org/demos/3d-surface-plotter/

L²平方的平方 (Squared L² Norm)

https://academo.org/demos/3d-surface-plotter/https://academo.org/demos/3d-surface-plotter/

The squared L2 norm and L2 norm look similar but there is an important difference here with respect to the steepness of the plot near the zero mark(in the middle blue region). The square L2 norm doesn’t differentiate well between zero and other smaller values. Thus this uncovers one problem with its use.

平方的L2范数和L2范数看起来相似,但是在这里,关于零标记(中间蓝色区域)附近的图的陡度存在重要差异。 平方L2范数不能很好地区分零和其他较小的值。 因此,这揭示了其使用中的一个问题。

摘要 (Summary)

In this tutorial, we looked at different ways to calculate vector lengths or magnitudes, called the vector norms.

在本教程中,我们研究了计算向量长度或大小的不同方法,称为向量范数。

Specifically, we learned how to:

具体来说,我们学习了如何:

  • calculate the L1 norm which is calculated as the sum of the absolute values of the vector.计算L1范数,该范数被计算为向量的绝对值之和。
  • calculate the L2 norm that is calculated as the square root of the sum of the squared vector values.计算L2范数,该L2范数被计算为平方的矢量值之和的平方根。
  • calculate the max norm which is calculated as the maximum vector values.计算最大范数,该最大范数被计算为最大矢量值。

Harshit的数据科学 (Data Science with Harshit)

With this channel, I am planning to roll out a couple of series covering the entire data science space. Here is why you should be subscribing to the channel:

通过这个渠道,我计划推出一系列涵盖整个数据科学领域的系列文章 。 这就是为什么您要订阅该频道的原因 :

  • These series would cover all the required/demanded quality tutorials on each of the topics and subtopics like Python fundamentals for Data Science.

    这些系列将涵盖关于每个主题和子主题(如数据科学的Python基础知识)的所有必需/要求的质量教程。

  • Explained Mathematics and derivations of why we do what we do in ML and Deep Learning.

    解释了数学以及为何我们在ML和深度学习中所做的事情的推导 。

  • Podcasts with Data Scientists and Engineers at Google, Microsoft, Amazon, etc, and CEOs of big data-driven companies.

    Google,Microsoft,Amazon等的数据科学家和工程师以及大数据驱动公司的CEO进行的播客 。

  • Projects and instructions to implement the topics learned so far. Learn about new certifications, Bootcamp, and resources to crack those certifications like this TensorFlow Developer Certificate Exam by Google.

    实施到目前为止所学主题的项目和说明 。 了解新的认证,Bootcamp以及破解这些认证的资源,例如Google的TensorFlow开发人员证书考试。

翻译自: https://towardsdatascience.com/calculating-vector-p-norms-linear-algebra-for-data-science-iv-400511cffcf0

线性代数 范数


http://www.taodudu.cc/news/show-4178567.html

相关文章:

  • 现代控制理论公式大赏
  • VSLAM学习记录-求导:李群与李代数
  • 李群和李代数以及李代数求导(扰动模型)
  • SLAM④----李群与李代数
  • 在 VSLAM 的后端优化中的重投影误差的雅可比计算详细推导
  • 使用VMware安装Ubuntu虚拟机 - 完整教程
  • Ubuntu完全教程
  • 模仿dos窗口下的windows窗口程序
  • 自己的第一个windows程序
  • 成品入库过账bapi
  • BAPI_GOODSMVT_CREATE移库操作(WMS TO SAP)
  • 【转载】BAPI_GOODSMVT_CREATE FUNCITON FOR MIGO 各种移动类型 源代码参考
  • SAP货物移动BAPI BAPI_GOODSMVT_CREATE(WMS TO SAP)
  • SAP BAPI BAPI_GOODSMVT_CREATE Goods movement
  • SAP 货物移动相关Bapi
  • C# 博思得 POSTEK 打印机 打码机 SDK 二次开发 指令打印
  • Postek博思得打印机
  • PTK(Pulmonarytoolkit)环境搭建与 ITK4.13+VS2015的配置
  • 看我横向打你内网--PthPtk
  • 内网渗透- *** PTH(传递哈希)***PTT(传递票据)***PTK(传递密钥)
  • 日文發音中的PTK法則
  • Kali linux 学习笔记(三十一)无线渗透——密钥交换(PTK)2020.3.11
  • 【内网渗透】域横向PTHPTKPTT哈希票据传递
  • 5.内网渗透之PTHPTTPTK
  • Micron(美光)内存颗粒的命名规则,7lk17d9PTK,MT29F2G08ABAEA(矿机自带)
  • AD域渗透 | PTHPTK哈希传递攻击手法
  • 内网安全-域横向PTHPTKPTT哈希票据传递
  • 哈希传递PTH、密钥传递PTT、票据传递PTK的实现和比较
  • 内网安全(四)---横向渗透:PTHPTKPTT
  • 内网域横向PTHPTKPTT哈希票据传递

线性代数 范数_计算数据科学的向量p范数线性代数iv相关推荐

  1. 线性代数中两个向量相乘_加两个向量| Python的线性代数

    线性代数中两个向量相乘 Prerequisite: Linear Algebra | Defining a Vector 先决条件: 线性代数| 定义向量 In the python code, we ...

  2. 线性代数向量乘法_标量乘法属性1 | 使用Python的线性代数

    线性代数向量乘法 Prerequisite: Linear Algebra | Defining a Vector 先决条件: 线性代数| 定义向量 Linear algebra is the bra ...

  3. python 向量二范数_向量的范数| 使用Python的线性代数

    python 向量二范数 Prerequisite: 先决条件: Defining Vector using Numpy 使用Numpy定义向量 Here, we are going to learn ...

  4. [线性代数] 向量的范数(Norm)

    [线性代数] 向量的范数(Norm): ​ 向量范数是向量模(长度)这一概念的推广.向量的L-p范数是一个标量,定义为: ∣∣x∣∣p=(∑i=1n∣xi∣p)1p||x||_p = (\sum_{i ...

  5. Matlab与线性代数 -- 向量的范数

    Matlab与线性代数 – 向量的范数

  6. 向量范数证明例题_第八课:向量的范数

    写在前面的话: 很高兴能够认识饭卡里还有好多钱这位土豪大佬.向大佬学习,为成为一名真正的段子手+逗比而奋斗. 范数的概念 向量的范数是一种用来刻画向量大小的一种度量.实数的绝对值,复数的模,三维空间向 ...

  7. 编译原理 数据流方程_数据科学中最可悲的方程式

    编译原理 数据流方程 重点 (Top highlight) Prepare a box of tissues! I'm about to drop a truth bomb about statist ...

  8. 矩阵论及其应用_数值分析篇——向量和矩阵的范数

    向量.矩阵范数 是数学中矩阵论.线性代数.泛函分析等领域中常见的基本概念,是将一定的矩阵空间建立为赋范向量空间时为矩阵装备的范数.应用中常将有限维赋范向量空间之间的映射以矩阵的形式表现,这时映射空间上 ...

  9. 点乘 线性代数_如果看了这些还不懂线性代数,你就来锤我和广坤

    引言:线性代数是数据科学的基础知识之一,3Blue1Brown也是非常有名的数学讲解频道.去年TDU的谢洛克在学习过3Blue1Brown线性代数的视频后,写下了备受欢迎的两篇学习笔记,再次分享给大家 ...

最新文章

  1. 语义分割损失函数系列(1):交叉熵损失函数
  2. iOS中的图像处理(一)——基础滤镜
  3. android 视频编码vfr cfr,[转载]VFR的源转换CRF输出 批处理
  4. ImageMagick的下载和配置
  5. 2019牛客多校第一场I Points Division(DP)题解
  6. UI界面视觉设计之字体要素--安卓-ios-网页常用字体
  7. 第五次打卡 模型融合
  8. [渝粤教育] 西南石油大学 钻井与完井工程 参考 资料
  9. mysql insert on duplicate_一条Insert on duplicate引发的血案
  10. 世界上第一次网络瘫痪 | 历史上的今天
  11. 计算机磁盘文件怎么加密,win10怎样对电脑硬盘文件进行加密 windows10给电脑硬盘文件加密教程...
  12. 2019大疆秋招面经(后台开发录用)
  13. 【机器学习必备知识】NumPy线性代数详解
  14. 爽啊!写了一个网页:首字母索引的单词(十分垃圾,简单的不得了)
  15. 什么时候应该卖掉基金
  16. 爆肝!朋友做了个编程导航网站!
  17. 手机软件开发环境种类介绍(转)
  18. 自定义echarts地图展示行政区域
  19. go在win环境下编译linux可执行文件
  20. 什么软件测试144hz显示器,1500R曲面的144Hz电竞显示器 飞利浦242M7评测

热门文章

  1. 通过 iptables 禁止 ping
  2. 转录组入门(2):读文章拿到测序数据
  3. 第三篇:读《今日简史》
  4. linux sd卡 分区变大,Linux下使用fdisk命令将高容量SD卡(SDHC)格成两个分区
  5. 【计算机网络】(4)什么是路由+ARP协议
  6. 华三防火墙三层逻辑子接口对接华三交换机
  7. excel中录制宏只执行一半的命令,没有执行全部如何解决?
  8. uniapp 如何将输入值转成大写
  9. x%3e=y%3e=z的c语言表达式,我的C语学习笔记-C语言教程(三).doc
  10. 统一信用代码n开头_股票代码查询怎么查,通过板块查找股票