关于矩阵迹的一些求导法则
一、迹的基本性质
- 线性性质:$tr(\sum_ic_iA_i)=\sum_ic_itr(A_i)$
- 转置不变性:$tr(A)=tr(A^T)$
- 轮换不变性 $tr(ABC)=tr(BCA)=tr(CAB)$
注意:轮换不变性不等于交换性,例如$tr(ABC)\neq tr(ACB)$
二、范数与迹的关系
- $\Vert X\Vert_\mathcal{F}^2=tr(X^TX)=\sum_{i=1}^m\sum_{j=1}^na_{ij}^2$
三、迹的求导规则
$\dfrac{\partial tr(AB)}{\partial A}=\dfrac{\partial tr(BA)}{\partial A}=B^T$
$\dfrac{\partial tr(A^TB)}{\partial A}=\dfrac{\partial tr(BA^T)}{\partial A}=B$
$\dfrac{\partial tr(A^TBA)}{\partial A}=BA+B^TA$
$\dfrac{\partial (ABA^T)}{\partial A}=AB^T+AB$
$\dfrac{\partial tr(AXBXC^T)}{\partial X}=A^TCX^TB^T+B^TX^TA^TC$
$\dfrac{\partial tr(AXBX)}{\partial X}=A^TX^TB^T+B^TX^TA^T$
$\dfrac{\partial tr(AXBX^T)}{\partial X}=A^TXB^T+AXB$
$\dfrac{\partial tr(A^TXB^T)}{\partial X}=\dfrac{\partial tr(AX^TB)}{\partial X}=AB$
$\dfrac{\partial tr(A^TXB)}{\partial X}=AB^T$
$\dfrac{\partial tr(A^TX^TXA)}{\partial X}=2XAA^T$
$\dfrac{\partial tr[(XA-B)^T(XA-B)]}{\partial X}=2(XA-B)A^T$
核心公式:$\nabla tr(XAX^TB)=B^TXA^T+BXA$