三个不同向量尺寸的全连接层进行拼接
时间: 2023-07-18 14:35:08 浏览: 39
假设三个向量分别为 $x_1 \in \mathbb{R}^{d_1}$,$x_2 \in \mathbb{R}^{d_2}$ 和 $x_3 \in \mathbb{R}^{d_3}$,我们可以使用全连接层对每个向量进行线性变换和非线性变换,得到三个新的向量 $h_1 \in \mathbb{R}^{h}$,$h_2 \in \mathbb{R}^{h}$ 和 $h_3 \in \mathbb{R}^{h}$,其中 $h$ 是全连接层的输出维度。具体地,我们可以使用以下公式计算:
$$h_1 = \sigma(W_1 x_1 + b_1)$$
$$h_2 = \sigma(W_2 x_2 + b_2)$$
$$h_3 = \sigma(W_3 x_3 + b_3)$$
其中 $\sigma$ 是激活函数,$W_1 \in \mathbb{R}^{h \times d_1}$,$b_1 \in \mathbb{R}^{h}$,$W_2 \in \mathbb{R}^{h \times d_2}$,$b_2 \in \mathbb{R}^{h}$,$W_3 \in \mathbb{R}^{h \times d_3}$,$b_3 \in \mathbb{R}^{h}$ 分别是三个全连接层的权重矩阵和偏置向量。
然后,我们将三个新的向量拼接成一个长向量 $h_{concat} \in \mathbb{R}^{3h}$,具体地,我们可以使用以下公式计算:
$$h_{concat} = [h_1; h_2; h_3]$$
其中 $[;]$ 表示拼接操作。最终,我们可以将 $h_{concat}$ 作为下一层神经网络的输入。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)