向量求导运算法则
前言
矩阵,向量的求导经常碰到和用到,但是老是忘记,在网上收集总结一下。
1.矩阵对元素的求导
矩阵对元素的求导比较简单,就是对矩阵的每个元素分别进行求导。
\[若:Y=
\begin{pmatrix}
y_{11} &\cdots & y_{1n} \\\
\vdots &\cdots & \vdots \\\
y_{m1} &\cdots & y_{mn}
\end{pmatrix}
\]
\[则:{\partial{Y} \over \partial{x}}=
\begin{pmatrix}
\partial{y_{11}} \over \partial{x} &\cdots & \partial{y_{1n}} \over \partial{x} \\\
\vdots &\cdots & \vdots \\\
\partial{y_{m1}} \over \partial{x} &\cdots & \partial{y_{mn}} \over \partial{x}
\end{pmatrix}
\]
2.元素对矩阵求导
\[{ \partial{x} \over \partial{Y}}=
\begin{pmatrix}
\partial{x} \over \partial{y_{11}} &\cdots & \partial{x} \over \partial{y_{1n}} \\\
\vdots &\cdots & \vdots \\\
\partial{x} \over \partial{y_{m1}} &\cdots & \partial{x} \over \partial{y_{mn}}
\end{pmatrix}
\]
3.行向量对列向量求导
\[若:Y=
\begin{bmatrix}
y_{1} &\cdots & y_{n}
\end{bmatrix},
X=
\begin{bmatrix}
x_{1} \\\ \vdots\\\ x_{m}
\end{bmatrix}
\]
\[则:
{ \partial{Y} \over \partial{X}}=
\begin{pmatrix}
\partial{y_1} \over \partial{x_{1}} &\cdots & \partial{y_n} \over \partial{x_{1}} \\\
\vdots &\cdots & \vdots \\\
\partial{y_1} \over \partial{x_{m}} &\cdots & \partial{y_n} \over \partial{x_{m}}
\end{pmatrix}
\]
4.行向量对行向量求导
\[若:Y=
\begin{bmatrix}
y_{1} &\cdots & y_{n}
\end{bmatrix},
X=
\begin{bmatrix}
x_{1} & \cdots & x_{p}
\end{bmatrix}
\]
\[则得到一个超级大的行向量:
{ \partial{Y} \over \partial{X}}=
\begin{bmatrix}
\partial{Y} \over \partial{x_{1}} &\cdots & \partial{Y} \over \partial{x_{p}}
\end{bmatrix}
\]
5.列向量对列向量求导
\[若:Y^T=
\begin{bmatrix}
y_{1} &\cdots & y_{n}
\end{bmatrix},
X^T=
\begin{bmatrix}
x_{1} & \cdots & x_{p}
\end{bmatrix}
\]
\[则得到一个超级大的列向量:
{ \partial{Y} \over \partial{X}}=
\begin{bmatrix}
\partial{Y} \over \partial{x_{1}} &\cdots & \partial{Y} \over \partial{x_{p}}
\end{bmatrix}^T
\]
6.矩阵对行向量求导\行向量对矩阵求导
\[若:Y=
\begin{pmatrix}
y_{11} &\cdots & y_{1n} \\\
\vdots &\cdots & \vdots \\\
y_{m1} &\cdots & y_{mn}
\end{pmatrix}
X=
\begin{bmatrix}
x_{1} & \cdots & x_{p}
\end{bmatrix}
\]
\[则:
{ \partial{Y} \over \partial{X}}=
\begin{bmatrix}
\partial{Y} \over \partial{x_{1}} &\cdots & \partial{Y} \over \partial{x_{p}}
\end{bmatrix}^T\\\
{ \partial{X} \over \partial{Y}}=
\begin{pmatrix}
\partial{X} \over \partial{y_{11}} &\cdots & \partial{X} \over \partial{y_{1n}} \\\
\vdots &\cdots & \vdots \\\
\partial{X} \over \partial{y_{m1}} &\cdots & \partial{X} \over \partial{y_{mn}}
\end{pmatrix}
\]
7.矩阵对列向量求导\列向量对矩阵求导
\[若:Y=
\begin{pmatrix}
y_{11} &\cdots & y_{1n} \\\
\vdots &\cdots & \vdots \\\
y_{m1} &\cdots & y_{mn}
\end{pmatrix}
X=
\begin{bmatrix}
x_{1} \\\ \vdots \\\ x_{p}
\end{bmatrix}
\]
\[则:
{ \partial{Y} \over \partial{X}}=
\begin{pmatrix}
\partial{y_1} \over \partial{X} &\cdots & \partial{y_n} \over \partial{X} \\\
\vdots &\cdots & \vdots \\\
\partial{y_1} \over \partial{X} &\cdots & \partial{y_n} \over \partial{X}
\end{pmatrix}\\\
{ \partial{X} \over \partial{Y}}=
\begin{bmatrix}
\partial{X_1} \over \partial{Y} \\\
\vdots \\\
\partial{X_p} \over \partial{Y}
\end{bmatrix}
\]
8.矩阵对矩阵求导
\[若:Y=
\begin{bmatrix}
y_{11} &\cdots & y_{1n} \\\
\vdots &\cdots & \vdots \\\
y_{m1} &\cdots & y_{mn}
\end{bmatrix}
=
\begin{bmatrix}
y_{1} \\\
\vdots \\\
y_{m}
\end{bmatrix};
X=
\begin{bmatrix}
x_{11} &\cdots & x_{1q} \\\
\vdots &\cdots & \vdots \\\
x_{p1} &\cdots & x_{pq}
\end{bmatrix}
=
\begin{bmatrix}
x_{1} & \cdots & x_{m}
\end{bmatrix}
\]
则:
\[{ \partial{Y} \over \partial{X}}=
\begin{bmatrix}
\partial{Y} \over \partial{x_1} & \cdots & \partial{Y} \over \partial{x_q}
\end{bmatrix}
=
\begin{bmatrix}
\partial{y_1} \over \partial{X} \\\
\vdots \\\
\partial{y_m} \over \partial{X}
\end{bmatrix}
=
\begin{bmatrix}
\partial{y_1} \over \partial{x_1} & \cdots & \partial{y_1} \over \partial{x_q} \\\
\vdots & \cdots & \vdots \\\
\partial{y_m} \over \partial{x_1} & \cdots & \partial{y_m} \over \partial{x_q}
\end{bmatrix}
\]