【发布时间】:2020-05-27 22:17:02
【问题描述】:
我正在尝试制作一个 RNN 模型(在 Pytorch 中),它需要几个句子,然后将其分类为 Class 0 或 Class 1。 p>
为了这个问题,我们假设句子的 max_len 为 4,时间步长的 max_amount 为 5。因此,每个数据点都在表单上(0 是用于填充填充值的值):
x[1] = [
# Input features at timestep 1
[1, 48, 91, 0],
# Input features at timestep 2
[20, 5, 17, 32],
# Input features at timestep 3
[12, 18, 0, 0],
# Input features at timestep 4
[0, 0, 0, 0],
# Input features at timestep 5
[0, 0, 0, 0]
]
y[1] = [1]
当我每个目标只有一个句子:我只是将每个单词传递给嵌入层,然后传递给 LSTM 或 GRU,但我有点卡住了当我有一个每个目标的句子序列时该怎么办?
如何构建可以处理句子的嵌入?
【问题讨论】:
标签: python neural-network pytorch recurrent-neural-network embedding