矩阵求导的思考

这两篇文章讲得很好。

矩阵求导术(上)
矩阵求导术(下)

比记公式靠谱多了。

对于求导的数学形式可以看看这个PPT。

http://wenku.baidu.com/link?url=f109MlZkctazXKxECYea-d5yFvU5xeub1jmFfq3z-UlsUGjbgam5tiAcCXYP9jb_RFM3RTMDU29u_RK9JB_lcjeR9AZa8uicQ1-sn9rOAe3

矩阵本质是方程组的系数,矩阵对列向量求导是方程组的每一个方程都对同样的一系列的变量求导。


2019 年 10 月 1 日更新。

这篇博客是我很久以前写的,2018 年 9 月时,博客中的图片就无法显示了,这是因为我使用的七牛云测试域名被收回。

最近看到了一本书上的内容可以解决这个问题。

这本书是 Peter, S. Maybeck. "Stochastic Models, Estimation, and Control. Vol. 1." (1979).,它的第一章 Appendix 10。现在截图如下:


偏导定义

向量 (mathbf{f})(p imes 1))对向量 (mathbf{x})(m imes 1))的导数是

[egin{align} frac{partial mathbf{f}}{partial mathbf{x}} = egin{bmatrix} frac{partial f_1}{partial x_1} & frac{partial f_2}{partial x_1} & dots & frac{partial f_p}{partial x_1} \ frac{partial f_1}{partial x_2} & frac{partial f_2}{partial x_2} & dots & frac{partial f_p}{partial x_2} \ vdots & vdots & ddots & vdots \ frac{partial f_1}{partial x_m} & frac{partial f_2}{partial x_m} & dots & frac{partial f_p}{partial x_m} end{bmatrix}end{align} ]

而导数和微分之间的关系是

[egin{align} ext{d}mathbf{f} = frac{partial mathbf{f}}{partial mathbf{x}}^T ext{d}mathbf{x} label{eq:diff_derivative} end{align} ]

对于( ef{eq:diff_derivative})的每一行,也就是 (mathbf{f}) 的单个元素,微分和导数之间的关系是

[egin{align} ext{d}f_i = frac{partial f_i}{partial x_1} ext{d}x_1 + frac{partial f_i}{partial x_2} ext{d}x_2 + cdots + frac{partial f_i}{partial x_m} ext{d}x_mend{align} ]

最小二乘推导

要求的误差平方和为一个标量,所以可以套用迹的形式。

结果推导如下:

偏导、Jacobian、梯度

偏导 (frac{partial mathbf{f}}{partial mathbf{x}}),Jacobian (mathbf{J}),梯度 ( abla_mathbf{x}mathbf{f})

之间能够确定的关系是 (mathbf{J} = abla_mathbf{x}mathbf{f}^T)

Jacobian 表达的意义一定是 ( ext{d}mathbf{f} = mathbf{J} ext{d}mathbf{x}),而梯度就是 ( ext{d}mathbf{f} = abla_mathbf{x}mathbf{f}^T ext{d}mathbf{x})

至于这个偏导 (frac{partial mathbf{f}}{partial mathbf{x}}) 表达什么意思,这个就是看个人习惯了,不同的习惯差一个转置。这可以参考维基百科词条 Matrix calculus

Two competing notational conventions split the field of matrix calculus into two separate groups. The two groups can be distinguished by whether they write the derivative of a scalar with respect to a vector as a column vector or a row vector. Both of these conventions are possible even when the common assumption is made that vectors should be treated as column vectors when combined with matrices (rather than row vectors).

以上 偏导定义 是按照知乎文章 矩阵求导术(下) 来写的。另一种表达方法是

[egin{align} frac{partial mathbf{f}}{partial mathbf{x}} = egin{bmatrix} frac{partial f_1}{partial x_1} & frac{partial f_1}{partial x_2} & dots & frac{partial f_1}{partial x_m} \ frac{partial f_2}{partial x_1} & frac{partial f_2}{partial x_2} & dots & frac{partial f_2}{partial x_m} \ vdots & vdots & ddots & vdots \ frac{partial f_p}{partial x_1} & frac{partial f_p}{partial x_2} & dots & frac{partial f_p}{partial x_m} end{bmatrix} end{align} ]

[egin{align} ext{d}mathbf{f} = frac{partial mathbf{f}}{partial mathbf{x}} ext{d}mathbf{x} end{align} ]

看别人的文字时,整理清楚看别人是怎么乘的,不要在乘 ( ext{d}mathbf{x}) 弄错。自己写的时候也先给出自己对偏导的定义。

原文地址:https://www.cnblogs.com/JingeTU/p/6519172.html