矩阵求导——Numerator Layout & Denominator Layout

2023-11-13

突然想起这个问题了,刚刚看到有人在问某个的公式,自己闷头想了想居然都忘的差不多了,于是乎稍微整理一下供以后参考。 
其实,关于矩阵求导讲的最详细的还是wiki上的页面面http://en.wikipedia.org/wiki/Matrix_calculus#Layout_conventions 
关于矩阵求导,很多地方会有不同的表现形式,说到底是这么一回事,一个m维的向量yy对n维的向量xx求导yx∂y∂x,得到的结果应该是m乘n还是n乘以m。具体内容可以看wikipedia。 
yy的元素以列的形式布局,xx以行的形式,或是反过来,这就导致了不同的可能性: 
分子布局(numerator layout):根据yy或者xTxT来布局,也叫Jacobian formulation 
分母布局(denominator layout):根据yTyT或者xx来布局,也叫Hessian formulation 
A third possibility sometimes seen is to insist on writing the derivative as yx∂y∂x′, (i.e. the derivative is taken with respect to the transpose of x) and follow the numerator layout. This makes it possible to claim that the matrix is laid out according to both numerator and denominator. In practice this produces results the same as the numerator layout.

When handling the [[gradient]] yx∂y∂x and the opposite case yx,∂y∂x, we have the same issues. To be consistent, we should do one of the following: 
If we choose numerator layout for yx,∂y∂x, we should lay out the [[gradient]] yx∂y∂x as a row vector, and yx∂y∂x as a column vector. 
If we choose denominator layout for yx,∂y∂x, we should lay out the [[gradient]] yx∂y∂x as a column vector, and yx∂y∂x as a row vector. 
In the third possibility above, we write yx∂y∂x′ andyx,∂y∂x, and use numerator layout.

Not all math textbooks and papers are consistent in this respect throughout the entire paper. That is, sometimes different conventions are used in different contexts within the same paper. For example, some choose denominator layout for gradients (laying them out as column vectors), but numerator layout for the vector-by-vector derivative yx.∂y∂x.

Similarly, when it comes to scalar-by-matrix derivatives yX∂y∂X and matrix-by-scalar derivatives Yx,∂Y∂x, then consistent numerator layout lays out according to ”YY”’ and ‘XTXT”, while consistent denominator layout lays out according to ”YTYT”and ”X”. In practice, however, following a denominator layout for Yx,∂Y∂x, and laying the result out according to ”YTYT”, is rarely seen because it makes for ugly formulas that do not correspond to the scalar formulas. As a result, the following layouts can often be found: 
”Consistent numerator layout”, which lays out Yx∂Y∂x according to ”YY′’ and yX∂y∂X according to ”XTXT”. 
”Mixed layout”, which lays out Yx∂Y∂x according to ”YY” and yX∂y∂X according to ”’X”’. 
Use the notation yXT,∂y∂XT,with results the same as consistent numerator layout.

In the following formulas, we handle the five possible combinations yx,yx,yx,yX∂y∂x,∂y∂x,∂y∂x,∂y∂X andYx∂Y∂x separately. We also handle cases of scalar-by-scalar derivatives that involve an intermediate vector or matrix. (This can arise, for example, if a multi-dimensional [[parametric curve]] is defined in terms of a scalar variable, and then a derivative of a scalar function of the curve is taken with respect to the scalar that parameterizes the curve.) For each of the various combinations, we give numerator-layout and denominator-layout results, except in the cases above where denominator layout rarely occurs. In cases involving matrices where it makes sense, we give numerator-layout and mixed-layout results. As noted above, cases where vector and matrix denominators are written in transpose notation are equivalent to numerator layout with the denominators written without the transpose.

Keep in mind that various authors use different combinations of numerator and denominator layouts for different types of derivatives, and there is no guarantee that an author will consistently use either numerator or denominator layout for all types. Match up the formulas below with those quoted in the source to determine the layout used for that particular type of derivative, but be careful not to assume that derivatives of other types necessarily follow the same kind of layout.

When taking derivatives with an aggregate (vector or matrix) denominator in order to find a maximum or minimum of the aggregate, it should be kept in mind that using numerator layout will produce results that are transposed with respect to the aggregate. For example, in attempting to find the [[maximum likelihood]] estimate of a [[multivariate normal distribution]] using matrix calculus, if the domain is a ”k”x1 column vector, then the result using the numerator layout will be in the form of a 1x”k” row vector. Thus, either the results should be transposed at the end or the denominator layout (or mixed layout) should be used. 
这里写图片描述

The results of operations will be transposed when switching between numerator-layout and denominator-layout notation.

=== Numerator-layout notation ===

Using numerator-layout notation, we have:Minka, Thomas P. “Old and New Matrix Algebra Useful for Statistics.” December 28, 2000. [http://research.microsoft.com/en-us/um/people/minka/papers/matrix/]


yx=[yx1yx2yxn].∂y∂x=[∂y∂x1∂y∂x2⋯∂y∂xn].

yx=y1xy2xymx.∂y∂x=[∂y1∂x∂y2∂x⋮∂ym∂x].

yx=y1x1y2x1ymx1y1x2y2x2ymx2y1xny2xnymxn.∂y∂x=[∂y1∂x1∂y1∂x2⋯∂y1∂xn∂y2∂x1∂y2∂x2⋯∂y2∂xn⋮⋮⋱⋮∂ym∂x1∂ym∂x2⋯∂ym∂xn].

yX=yx11yx12yx1qyx21yx22yx2qyxp1yxp2yxpq.∂y∂X=[∂y∂x11∂y∂x21⋯∂y∂xp1∂y∂x12∂y∂x22⋯∂y∂xp2⋮⋮⋱⋮∂y∂x1q∂y∂x2q⋯∂y∂xpq].

The following definitions are only provided in numerator-layout notation:

Yx=y11xy21xym1xy12xy22xym2xy1nxy2nxymnx.∂Y∂x=[∂y11∂x∂y12∂x⋯∂y1n∂x∂y21∂x∂y22∂x⋯∂y2n∂x⋮⋮⋱⋮∂ym1∂x∂ym2∂x⋯∂ymn∂x].

dX=dx11dx21dxm1dx12dx22dxm2dx1ndx2ndxmn.dX=[dx11dx12⋯dx1ndx21dx22⋯dx2n⋮⋮⋱⋮dxm1dxm2⋯dxmn].

===Denominator-layout notation=== 
Using denominator-layout notation, we have:[http://www.colorado.edu/engineering/CAS/courses.d/IFEM.d/IFEM.AppD.pdf] 

yx=yx1yx2yxn.∂y∂x=[∂y∂x1∂y∂x2⋮∂y∂xn].

yx=[y1xy2xymx].∂y∂x=[∂y1∂x∂y2∂x⋯∂ym∂x].

yx=y1x1y1x2y1xny2x1y2x2y2xnymx1ymx2ymxn.∂y∂x=[∂y1∂x1∂y2∂x1⋯∂ym∂x1∂y1∂x2∂y2∂x2⋯∂ym∂x2⋮⋮⋱⋮∂y1∂xn∂y2∂xn⋯∂ym∂xn].

yX=yx11yx21yxp1yx12yx22yxp2yx1qyx2qyxpq.∂y∂X=[∂y∂x11∂y∂x12⋯∂y∂x1q∂y∂x21∂y∂x22⋯∂y∂x2q⋮⋮⋱⋮∂y∂xp1∂y∂xp2⋯∂y∂xpq].

原文地址:https://blog.csdn.net/lansatiankongxxc/article/details/44992709

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

矩阵求导——Numerator Layout & Denominator Layout 的相关文章

  • windows平板找回完整的电源模式,包括高性能模式

    windows平板找回完整的电源模式 包括高性能模式 找回完整的电源模式 可以让你的平板关闭显示屏而不关机 甚至开启高性能模式等等 有这样需求的可以试试 博主是为了让台电X80HD的win8的平板可以关闭显示屏进行运行 从而可以利用其做一台
  • MySQL8.0.12 EXPLAIN EXTENDED 报错问题

    今天测试时发现有一条命令报错 explain EXTENDED SELECT count from OORDER where O CARRIER ID lt 10000 网上的教程都是explain EXTENDED 后来查看官方文档发现e
  • Open3D (C++) 点云随机渲染颜色

    目录 一 概述 二 代码实现 三 结果展示 一 概述 Open3D中颜色的取值范围是 0 0 1 0 C 中的函数rand 可以用来生成随机数 其返回值是整数 要生成0 0 1 0之间的浮点数 必须经过转换 首先生成一个0 N的随机数 再除
  • Hololens入门开发(二)unity项目设置及MR开发包导入

    一 新建一个u3d项目 二 将unity的平台切换为Universal Windows Platform 三 MR开发包导入 开发包链接来自Github 根据需要的版本进行选择 https github com microsoft Mixe
  • Exchange Server 2016 安装部署

    目录 0x01 简介 0x02 环境准备 0x03 添加角色与功能 配置Active Directory 域服务 0x04 安装ExchangeServer 点击 setup 不检查更新 点击 下一步 接受许可 不使用推荐设置 选择邮件角色
  • element-ui 整体替换主题色

    自定义主题 Element 默认提供一套主题 CSS 命名采用 BEM 的风格 方便使用者覆盖样式 我们提供了三种方法 可以进行不同程度的样式自定义 仅替换主题色 如果仅希望更换 Element 的主题色 推荐使用在线主题生成工具 Elem
  • MySQL锁之一:锁详解

    一 什么是死锁 死锁是指两个或两个以上的进程在执行过程中 因争夺资源而造成的一种互相等待的现象 若无外力作用 它们都将无法推进下去 此时称系统处于死锁状态或系统产生了死锁 这些永远在互相等的进程称为死锁进程 二 死锁产生的四个必要条件 互斥
  • Go-cli框架Cobra

    Cobra是前go语言负责人spf13开发的一款go cli框架 可以轻松规范的处理cli应用场景 项目地址 https github com spf13 cobra作者博客 https spf13 com 所谓官网 https cobra
  • len()函数

    len 函数 描述 len 函数返回对象 字符 列表 元组等 长度或项目个数 语法 len 方法语法 len s 参数 s 对象 返回值 返回对象长度 实例 以下实例展示了 len 的使用方法 str 1111111111111 print
  • Python 11 (paramiko模块,ssh密钥,进程线程,锁,信号量)

    本节内容 paramiko模块 基于SSH用于连接远程服务器并执行相关操作 paramiko模块 SSHClient 用于连接远程服务器并执行基本命令 基于用户名密码连接 Author yyqian import paramiko 创建SS
  • android studio f5,AndroidStudio 快捷鍵

    8种机械键盘轴体对比 本人程序员 要买一个写代码的键盘 请问红轴和茶轴怎么选 符號說明 gt option alt gt shift gt control gt command gt esc 注 与F6 F7 F12等F功能键开头的组合的快
  • java中String、StringBuffer、StringBuilder的区别

    java中String StringBuffer StringBuilder是编程中经常使用的字符串类 他们之间的区别也是经常在面试中会问到的问题 现在总结一下 看看他们的不同与相同 三者共同之处 都是final类 不允许被继承 主要是从性
  • msvcp140.dll丢失如何修复?win7丢失msvcp140.dll的修复方法

    有win7用户在操作电脑的过程中 遇到msvcp140 dll丢失的情况 这是怎么回事 一般是由于系统中丢失dll文件导致的 下面就和小编一起来看看具体的解决办法吧 MSVCP文件的版本 这是我电脑上安装的各版本 VC 版本间互相不重复 并
  • javac不是内部或外部命令,也不是可运行的程序 或批处理文件的细节问题(window10)

    目录 步骤一 找到JDK下的bin目录 运行cmd 输入javac 能提示 说明环境配置有问题 步骤二 cmd输入 path 步骤三 看看下载的JDK包解压后目录对不对 步骤四 检查是否有环境冲突 最后 环境变量配置 描述 打开cmd 输入
  • 前后台交互时客户端请求的中文字变成问号

    今天在写form表单的时候发现提交的中文字在后台接收的时候变成了 如下图 经过检查发现是编码格式的不统一的问题 前台给数据设置了编码格式 而后台没有设置编码格式 就造成了中文字不能识别
  • spring boot中web容器配置

    web容器配置 spring boot 默认的web容器是 tomcat 如果需要换成其他的 web 容器 可以如下配置
  • windows下nginx配置为服务

    1 下载winswx 下载地址 winsw下载 2 解压后将其重命名为 nginx service 并将其放到nginx目录下 3 新建一个文本文档内容如下 里面的路径根据自己的情况修改
  • mysql 8 窗口函数

    使用mysql8 遇到一个问题 分区之后排序 得到的结果不是预想中的值 而把排序取消之后 能够得到正确的结果 如图所示 搞不懂 大佬解释下
  • hadoop datanode没有启动

    datanode启动不了 即执行命令 bin hadoop namenode format 后 默认地址tmp hadoop 1 dfs data current VERSION namenod 和datanode 的clusterid不一

随机推荐