我是靠谱客的博主 悲凉萝莉,最近开发中收集的这篇文章主要介绍2 Main Layout Conventions of Matrix Calculus,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

考虑 (x), (y) 分别是 (n), (m) 维列向量, (A)(mtimes n) 矩阵, (z) 是标量.

Numerator Layout

想象分子不变, 分母转置.

Vector by vector 符合直观. Jacobian.

[ frac{partial y}{partial x} = begin{pmatrix} frac{partial y_1}{partial x_1} & dots & frac{partial y_1}{partial x_n}\ vdots & ddots &vdots\ frac{partial y_m}{partial x_1} & dots & frac{partial y_m}{partial x_n} end{pmatrix} ]

Scalar by matrix 要做一次转置, 不舒服.

[ frac{partial z}{partial A}= begin{pmatrix} frac{partial z}{partial a_{11}} & dots & frac{partial z}{partial a_{m1}}\ vdots & ddots &vdots\ frac{partial z}{partial a_{1n}} & dots & frac{partial z}{partial a_{mn}} end{pmatrix} ]

Chain rule 符合直观.

[ frac{partial fcirc g}{partial x} = frac{partial f}{partial g}frac{partial g}{partial x} ]

Denominator Layout

想象分母不变, 分子转置.

Vector by vector 不舒服. Hessian.

[ frac{partial y}{partial x} = begin{pmatrix} frac{partial y_1}{partial x_1} & dots & frac{partial y_m}{partial x_1}\ vdots & ddots &vdots\ frac{partial y_1}{partial x_n} & dots & frac{partial y_m}{partial x_n} end{pmatrix} ]

Scalar by matrix 舒服.

[ frac{partial z}{partial A}= begin{pmatrix} frac{partial z}{partial a_{11}} & dots & frac{partial z}{partial a_{1n}}\ vdots & ddots &vdots\ frac{partial z}{partial a_{m1}} & dots & frac{partial z}{partial a_{mn}} end{pmatrix} ]

Chain rule "倒过来" 了, 不舒服.

[ frac{partial fcirc g}{partial x} = frac{partial g}{partial x}frac{partial f}{partial g} ]

混用

混用现象很常见. 比如 CS224n, 主体是采用 numerator layout, 但是 scalar by matrix 时是不转置的.

转载于:https://www.cnblogs.com/shiina922/p/11435371.html

最后

以上就是悲凉萝莉为你收集整理的2 Main Layout Conventions of Matrix Calculus的全部内容,希望文章能够帮你解决2 Main Layout Conventions of Matrix Calculus所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部