【矩阵论】含卷积求导
本篇使用的符号说明,书接上回《含卷积矩阵优化问题的闭式解》,那么为什么会有这篇呢。
主要是求导部分不够严谨,实际上傅里叶变换后已经是复数了,求导规则不能完全参考实矩阵,因此本文尝试从另一个角度绕过对复矩阵求导可能会出现的问题。
考虑优化目标
\[\min\limits_K\|A*K-B\|_F^2,\tag{1}
\]
其中\(A,B,K\)均为实矩阵,这里卷积的实现我们后文会提。在这里我们考虑均为方阵方便推导,实际上一般矩阵也有相同的结论。对于二维矩阵的傅里叶变换,实现方式为
\[\mathcal{F}(X)=FXF,\mathcal{F}^{-1}(X)=F^{H}XF^{H}\tag{2}.
\]
其中\(F\)为傅里叶矩阵,同时有一个矩阵拉直的引理
\[\operatorname{vec}(ABC)=(C^T\otimes A)\operatorname{vec}(B). \tag{3}
\]
于是由傅里叶变换的性质,可以将\((1)\)进行变换
\[\begin{align}
&\|A*K-B\|_F^2 \notag\\
=&\|\mathcal{F}^{-1}(\mathcal{F}(A)\odot\mathcal{F}(K))-B\|_F^2.\tag{4}
\end{align}
\]
由于\(F\)-范数本质是逐位置求2-范数,因此可以将其拉直得到
\[\begin{aligned}
(4)&\Leftrightarrow\left\|\operatorname{vec}(\mathcal{F}^{-1}(\mathcal{F}(A)\odot\mathcal{F}(K)))-\bm{b}\right\|^2,\bm{b}=\operatorname{vec}(B) \\
&=\left\|\operatorname{vec}(F^H(\mathcal{F}(A)\odot\mathcal{F}(K))F^H)-\bm{b}\right\|^2 \\
&=\left\|(F^H\otimes F^H)\operatorname{vec}(\mathcal{F}(A)\odot\mathcal{F}(K))-\bm{b}\right\|^2 \\
&=\left\|(F^H\otimes F^H)\operatorname{vec}(\mathcal{F}(A))\odot\operatorname{vec}(\mathcal{F}(K))-\bm{b}\right\|^2 \\
&=\left\|(F^H\otimes F^H)\operatorname{diag}(\operatorname{vec}(\mathcal{F}(A)))\cdot\operatorname{vec}(\mathcal{F}(K))-\bm{b}\right\|^2 \\
&=\left\|(F^H\otimes F^H)\operatorname{diag}(\operatorname{vec}(\mathcal{F}(A)))(F\otimes F)(F^H\otimes F^H)\operatorname{vec}(\mathcal{F}(K))-\bm{b}\right\|^2 \\
&=\left\|(F^H\otimes F^H)\operatorname{diag}(\operatorname{vec}(\mathcal{F}(A)))(F\otimes F)\operatorname{vec}(K)-\bm{b}\right\|^2.
\end{aligned}\]
令\(D=(F^H\otimes F^H)\operatorname{diag}(\operatorname{vec}(\mathcal{F}(A)))(F\otimes F)\),于是有
\[\operatorname{vec}(A*K)=D\cdot\operatorname{vec}(K),
\]
由于\(A,K\)为实矩阵,于是\(A*K\)为实矩阵,令\(K\)为\(1\times1\)卷积核,由\(K\)的任意性可知\(D\)为实矩阵。令\(\bm{k}=\operatorname{vec}(K)\),将优化目标对\(\bm{k}\)求导得到
\[\begin{aligned}
\frac{\partial}{\partial\bm{k}}\|D\bm{k}-\bm{b}\|&=2D^T(D\bm{k}-\bm{b}) \\
&=2D^H(D\bm{k}-\bm{b}) \\
&=2(F^H\otimes F^H)\overline{\operatorname{diag}(\operatorname{vec}(\mathcal{F}(A)))}(F\otimes F)\left[(F^H\otimes F^H)\operatorname{diag}(\operatorname{vec}(\mathcal{F}(A)))(F\otimes F)\bm{k}-\bm{b}\right]=0
\end{aligned}\\
\begin{aligned}
\Rightarrow (F^H\otimes F^H)\overline{\operatorname{diag}(\operatorname{vec}(\mathcal{F}(A)))}\operatorname{diag}(\operatorname{vec}(\mathcal{F}(A)))(F\otimes F)\bm{k}&=(F^H\otimes F^H)\overline{\operatorname{diag}(\operatorname{vec}(\mathcal{F}(A)))}(F\otimes F)\bm{b}
\end{aligned}
\]