今天推导公式,发现居然有对矩阵的求导,狂汗--完全不会。不过还好网上有人总结了。吼吼,赶紧搬过来收藏备份。

基本公式:
Y = A * X --> DY/DX = A'
Y = X * A --> DY/DX = A
Y = A' * X * B --> DY/DX = A * B'
Y = A' * X' * B --> DY/DX = B * A'

1. 矩阵Y对标量x求导:

相当于每个元素求导数后转置一下,注意M×N矩阵求导后变成N×M了

Y = [y(ij)] --> dY/dx = [dy(ji)/dx]

2. 标量y对列向量X求导:

注意与上面不同,这次括号内是求偏导,不转置,对N×1向量求导后还是N×1向量

y = f(x1,x2,..,xn) --> dy/dX = (Dy/Dx1,Dy/Dx2,..,Dy/Dxn)'

3. 行向量Y'对列向量X求导:

注意1×M向量对N×1向量求导后是N×M矩阵。

将Y的每一列对X求偏导,将各列构成一个矩阵。

重要结论:

dX'/dX = I

d(AX)'/dX = A'

4. 列向量Y对行向量X’求导:

转化为行向量Y’对列向量X的导数,然后转置。

注意M×1向量对1×N向量求导结果为M×N矩阵。

dY/dX' = (dY'/dX)'

5. 向量积对列向量X求导运算法则:

注意与标量求导有点不同。

d(UV')/dX = (dU/dX)V' + U(dV'/dX)

d(U'V)/dX = (dU'/dX)V + (dV'/dX)U'

重要结论:

d(X'A)/dX = (dX'/dX)A + (dA/dX)X' = IA + 0X' = A

d(AX)/dX' = (d(X'A')/dX)' = (A')' = A

d(X'AX)/dX = (dX'/dX)AX + (d(AX)'/dX)X = AX + A'X

6. 矩阵Y对列向量X求导:

将Y对X的每一个分量求偏导,构成一个超向量。

注意该向量的每一个元素都是一个矩阵。

7. 矩阵积对列向量求导法则:

d(uV)/dX = (du/dX)V + u(dV/dX)

d(UV)/dX = (dU/dX)V + U(dV/dX)

重要结论:

d(X'A)/dX = (dX'/dX)A + X'(dA/dX) = IA + X'0 = A

8. 标量y对矩阵X的导数:

类似标量y对列向量X的导数,

把y对每个X的元素求偏导,不用转置。

dy/dX = [ Dy/Dx(ij) ]

重要结论:

y = U'XV = ΣΣu(i)x(ij)v(j) 于是 dy/dX = [u(i)v(j)] = UV'

y = U'X'XU 则 dy/dX = 2XUU'

y = (XU-V)'(XU-V) 则 dy/dX = d(U'X'XU - 2V'XU + V'V)/dX = 2XUU' - 2VU' + 0 = 2(XU-V)U'

9. 矩阵Y对矩阵X的导数:

将Y的每个元素对X求导,然后排在一起形成超级矩阵。

10.乘积的导数

d(f*g)/dx=(df'/dx)g+(dg/dx)f'

结论

d(x'Ax)=(d(x'')/dx)Ax+(d(Ax)/dx)(x'')=Ax+A'x   (注意:''是表示两次转置)

比较详细点的如下:

http://lzh21cen.blog.163.com/blog/static/145880136201051113615571/

http://hi.baidu.com/wangwen926/blog/item/eb189bf6b0fb702b720eec94.html

其他参考:

Contents

  • Notation
  • Derivatives of Linear Products
  • Derivatives of Quadratic Products

Notation

  • d/dx (y) is a vector whose (i) element is dy(i)/dx
  • d/dx (y) is a vector whose (i) element is dy/dx(i)
  • d/dx (yT) is a matrix whose (i,j) element is dy(j)/dx(i)
  • d/dx (Y) is a matrix whose (i,j) element is dy(i,j)/dx
  • d/dX (y) is a matrix whose (i,j) element is dy/dx(i,j)

Note that the Hermitian transpose is not used because complex conjugates are not analytic.

In the expressions below matrices and vectors ABC do not depend on X.

Derivatives of Linear Products

  • d/dx (AYB) =A * d/dx (Y) * B
    • d/dx (Ay) =A * d/dx (y)
  • d/dx (xTA) =A
    • d/dx (xT) =I
    • d/dx (xTa) = d/dx (aTx) = a
  • d/dX (aTXb) = abT
    • d/dX (aTXa) = d/dX (aTXTa) = aaT
  • d/dX (aTXTb) = baT
  • d/dx (YZ) =Y * d/dx (Z) + d/dx (Y) * Z

Derivatives of Quadratic Products

  • d/dx (Ax+b)TC(Dx+e) = ATC(Dx+e) + DTCT(Ax+b)
    • d/dx (xTCx) = (C+CT)x
      • [C: symmetric]: d/dx (xTCx) = 2Cx
      • d/dx (xTx) = 2x
    • d/dx (Ax+b)T (Dx+e) = AT (Dx+e) + DT (Ax+b)
      • d/dx (Ax+b)T (Ax+b) = 2AT (Ax+b)
    • [C: symmetric]: d/dx (Ax+b)TC(Ax+b) = 2ATC(Ax+b)
  • d/dX (aTXTXb) = X(abT + baT)
    • d/dX (aTXTXa) = 2XaaT
  • d/dX (aTXTCXb) = CTXabT + CXbaT
    • d/dX (aTXTCXa) = (C + CT)XaaT
    • [C:Symmetricd/dX (aTXTCXa) = 2CXaaT
  • d/dX ((Xa+b)TC(Xa+b)) = (C+CT)(Xa+b)aT

Derivatives of Cubic Products

  • d/dx (xTAxxT) = (A+AT)xxT+xTAxI

Derivatives of Inverses

  • d/dx (Y-1) = -Y-1d/dx (Y)Y-1

Derivative of Trace

Note: matrix dimensions must result in an n*n argument for tr().

  • d/dX (tr(X)) = I
  • d/dX (tr(Xk)) =k(Xk-1)T
  • d/dX (tr(AXk)) = SUMr=0:k-1(XrAXk-r-1)T
  • d/dX (tr(AX-1B)) = -(X-1BAX-1)T
    • d/dX (tr(AX-1)) =d/dX (tr(X-1A)) = -X-TATX-T
  • d/dX (tr(ATXBT)) = d/dX (tr(BXTA)) = AB
    • d/dX (tr(XAT)) = d/dX (tr(ATX)) =d/dX (tr(XTA)) = d/dX (tr(AXT)= A
  • d/dX (tr(AXBXT)) = ATXBT + AXB
    • d/dX (tr(XAXT)) = X(A+AT)
    • d/dX (tr(XTAX)) = XT(A+AT)
    • d/dX (tr(AXTX)) = (A+AT)X
  • d/dX (tr(AXBX)) = ATXTBT + BTXTAT
  • [C:symmetricd/dX (tr((XTCX)-1A) = d/dX (tr(A (XTCX)-1) = -(CX(XTCX)-1)(A+AT)(XTCX)-1
  • [B,C:symmetricd/dX (tr((XTCX)-1(XTBX)) = d/dX (tr( (XTBX)(XTCX)-1) = -2(CX(XTCX)-1)XTBX(XTCX)-1 + 2BX(XTCX)-1

Derivative of Determinant

Note: matrix dimensions must result in an n*n argument for det().

  • d/dX (det(X)) = d/dX (det(XT)) = det(X)*X-T
    • d/dX (det(AXB)) = det(AXB)*X-T
    • d/dX (ln(det(AXB))) = X-T
  • d/dX (det(Xk)) = k*det(Xk)*X-T
    • d/dX (ln(det(Xk))) = kX-T
  • [Real] d/dX (det(XTCX)) = det(XTCX)*(C+CT)X(XTCX)-1
    • [CReal,Symmetricd/dX (det(XTCX)) = 2det(XTCX)* CX(XTCX)-1
  • [CReal,Symmetriccd/dX (ln(det(XTCX))) = 2CX(XTCX)-1

Jacobian

If y is a function of x, then dyT/dx is the Jacobian matrix of y with respect to x.

Its determinant, |dyT/dx|, is the Jacobian of y with respect to x and represents the ratio of the hyper-volumes dy and dx. The Jacobian occurs when changing variables in an integration: Integral(f(y)dy)=Integral(f(y(x)) |dyT/dx| dx).

Hessian matrix

If f is a function of x then the symmetric matrix d2f/dx2 = d/dxT(df/dx) is the Hessian matrix of f(x). A value of x for which df/dx = 0 corresponds to a minimum, maximum or saddle point according to whether the Hessian is positive definite, negative definite or indefinite.

  • d2/dx2 (aTx) = 0
  • d2/dx2 (Ax+b)TC(Dx+e) = ATCD + DTCTA
    • d2/dx2 (xTCx) = C+CT
      • d2/dx2 (xTx) = 2I
    • d2/dx2 (Ax+b)T (Dx+e) = ATD + DTA
      • d2/dx2 (Ax+b)T (Ax+b) = 2ATA
    • [C: symmetric]: d2/dx2 (Ax+b)TC(Ax+b) = 2ATCA  
http://www.psi.toronto.edu/matrix/calculus.html
 

[zt]矩阵求导公式的更多相关文章

  1. 机器学习基石:Homework #0 SVD相关&常用矩阵求导公式

  2. AI 矩阵求导

    矩阵求导 参考链接: https://en.wikipedia.org/wiki/Matrix_calculus#Scalar-by-vector_identities

  3. Floating-Point Hazard【求导公式】

    Floating-Point Hazard 题目链接(点击) 题目描述 Given the value of low, high you will have to find the value of ...

  4. 【Math】矩阵求导

    https://en.wikipedia.org/wiki/Matrix_calculus http://blog.sina.com.cn/s/blog_7959e7ed0100w2b3.html

  5. 关于 RNN 循环神经网络的反向传播求导

    关于 RNN 循环神经网络的反向传播求导 本文是对 RNN 循环神经网络中的每一个神经元进行反向传播求导的数学推导过程,下面还使用 PyTorch 对导数公式进行编程求证. RNN 神经网络架构 一个 ...

  6. OO_BLOG1_简单表达式求导问题总结

    作业1-1 包含简单幂函数的多项式导函数的求解 I. 基于度量的程序结构分析 1)程序结构与基本度量统计图 2)分析 ​ 本人的第一次作业的程序实现逻辑十分简单,但是OOP的色彩并不强烈,程序耦合度过 ...

  7. 向量的L2范数求导

    回归中最为基础的方法, 最小二乘法. \[ \begin{align*} J_{LS}{(\theta)} &= \frac { 1 }{ 2 } { \left\| A\vec { x } ...

  8. 2019 OO第一单元总结(表达式求导)

    一. 基于度量的程序结构分析 1. 第一次作业 这次作业是我上手的第一个java程序,使用了4个类来实现功能.多项式采用两个arraylist来存,系数和幂指数一一对应. private ArrayL ...

  9. Pytorch之Variable求导机制

    自动求导机制是pytorch中非常重要的性质,免去了手动计算导数,为构建模型节省了时间.下面介绍自动求导机制的基本用法. #自动求导机制 import torch from torch.autogra ...

随机推荐

  1. 解决因为I_JOB_NEXT问题导致job执行不正常,不停生成trace文件问题

    今天同事说有个项目生产环境的目录老是满.查看了一下bdump目录,发现确实是平均1分钟生成一个8M左右的trace文件.查询了一下alert日志,发现是个job的报错引起的.具体查看了一下trace文 ...

  2. ubuntu12.04 安装eclipse

    1:去官网下载最新版的eclipse for linux; 2:cd  /usr/local 用命令 sudo mkdir eclipse 建立一个Eclipse的目录 3:将下载的文件copy到ec ...

  3. struct 类型重定义

    类型定义的那个头文件只需要在功能源文件里#include 开始在主函数源文件里也#include,所以出现了重定义

  4. 自定义 ActionBar 标题与菜单中的文字样式

    自定义标题文字样式 标题样式是 ActionBar 样式的一部分,所以要先定义 ActionBar 的样式 <style name="AppTheme" parent=&qu ...

  5. 学习笔记总结---关于sass

    今天跟大家共同分享交流一下关于sass的知识点: sass的产生: css不是一种编程语言,我们可以用它开发网页样式,但不能用它进行编程.它没有常量,变量,也没有条件语句,只是对属性一行行的描述,资料 ...

  6. 移动网页 -- CSS布局

    1.多栏结构 column-count column-width column:120px 3: column-gap:2em: column-rule:2px dotted gray: 跨越以及打断 ...

  7. js-高级技术

    高级技术: 1.function Person(name,age,job){ this.name=name; this.age=age; this.job=job; } var person=new ...

  8. Git 使用命令

    $ git add . $ git commit -m "html files created 20160308 16:08" $ git push origin master 设 ...

  9. CodeForces 520B Two Buttons

    Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description Vasya ...

  10. Mvc网站发布到IIS

    网站发布步骤: 这部分是转载文章 在此标明出处,以前有文章是转的没标明的请谅解,因为有些已经无法找到出处,或者与其它原因. 如有冒犯请联系本人,或删除,或标明出处. 因为好的文章,以前只想收藏,但连接 ...