bn+dense+dn 融合

bn+dense+dn 融合#

若: $\( \begin{cases} a_i = (a_i^1, \cdots, a_i^n)^T \in \mathbb{R}^{n \times 1} \\ s_A = (s_A^1, \cdots, s_A^n)^T \in \mathbb{R}^{n \times 1} \\ r_A = (r_A^1, \cdots, r_A^n)^T \in \mathbb{R}^{n \times 1} \\ b_j = (b_j^1, \cdots, b_j^n)^T \in \mathbb{R}^{n \times 1} \\ s_B = (s_B^1, \cdots, s_B^k)^T \in \mathbb{R}^{k \times 1} \\ r_B = (r_B^1, \cdots, r_B^k)^T \in \mathbb{R}^{k \times 1} \\ A = \begin{bmatrix} a_1^T \\ a_2^T \\ \vdots \\ a_m^T \end{bmatrix} \in \mathbb{R}^{m \times n} \\ B = \begin{bmatrix} b_1^T \\ b_2^T \\ \vdots \\ b_k^T \end{bmatrix} \in \mathbb{R}^{k \times n} \end{cases} \)$

则有

\[\begin{split} \begin{cases} <a_i, b_j> = a_i^T b_j = \sum_{p=1}^n a_i^p b_j^p \in \mathbb{R}\\ <A, B> = A B^T = \begin{bmatrix} <a_i, b_j> \end{bmatrix}_{m \times k} \in \mathbb{R}^{m \times k}\\ A \odot s_A^T = \begin{bmatrix} (a_1 \odot s_A)^T \\ \vdots \\ (a_m \odot s_A)^T \end{bmatrix}_{m \times n} \in \mathbb{R}^{m \times n} \\ A \oplus r_A^T = \begin{bmatrix} (a_1 \oplus r_A)^T \\ \vdots \\ (a_m \oplus r_A)^T \end{bmatrix}_{m \times n} \in \mathbb{R}^{m \times n} \end{cases} \end{split}\]

进一步有

\[\begin{split} A \odot s_A^T \oplus r_A^T = \begin{bmatrix} (a_1 \odot s_A \oplus r_A)^T \\ \vdots \\ (a_m \odot s_A \oplus r_A)^T \end{bmatrix}_{m \times n} \in \mathbb{R}^{m \times n} $$,\end{split}\]
(1)#\[\begin{align} <A \odot s_A^T \oplus r_A^T, B> &= \begin{bmatrix} \sum_{p=1}^n (a_i^p s_A^p + r_A^p)b_j^p \end{bmatrix}_{m \times k} \\ &= \begin{bmatrix} a_i^T (b_j \odot s_A) + \sum_{p=1}^n r_A^pb_j^p \end{bmatrix}_{m \times k} \\ &= \begin{bmatrix} a_i^T (b_j \odot s_A) + 1_{1\times n}^T (b_j \odot r_A) \end{bmatrix}_{m \times k} \\ \end{align}\]

$$