zoukankan      html  css  js  c++  java
  • 矩阵求导的思考

    这两篇文章讲得很好。

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

    比记公式靠谱多了。

    对于求导的数学形式可以看看这个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}) 弄错。自己写的时候也先给出自己对偏导的定义。

  • 相关阅读:
    App测试从入门到精通之安装、卸载和运行测试
    App测试从入门到精通之App分类和场景操作系统
    一步到位带你入门Selenium
    MAMP和WAMP搭建Web环境,数据库,数据分布可视化
    爬虫 Http请求,urllib2获取数据,第三方库requests获取数据,BeautifulSoup处理数据,使用Chrome浏览器开发者工具显示检查网页源代码,json模块的dumps,loads,dump,load方法介绍
    Python 基本语法,文件读写,数据结构和类型
    python 数据工程 and 开发工具Sublime
    jieba user guide
    python各类项目模块记录
    python parse xml using DOM
  • 原文地址:https://www.cnblogs.com/JingeTU/p/6519172.html
Copyright © 2011-2022 走看看