graykode / graykode/nlp-tutorial

Bi-LSTM attention calc may be wrong

未关闭
#68 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Jupyter Notebook
星标
14.9k
派生
3.9k
PR 合并指标
30 天内没有已合并 PR

描述

# lstm_output : [batch_size, n_step, n_hidden * num_directions(=2)], F matrix
def attention_net(self, lstm_output, final_state):
batch_size = len(lstm_output)
hidden_forward=final_state[0]
hidden_backward=final_state[1]
hidden_f_b=torch.cat((hidden_forward, hidden_backward), 1)
hidden = hidden_f_b.view(batch_size, -1, 1) #
hidden = final_state.view(batch_size, -1, 1) # this line in source code is wrong, bi-lstm's hidden is[2,batch,embed_size] ,we need to concatenate forward and backward hidden state. if we final_state.view(batch_size, -1, 1) the hidden state is not concatenate by final_state[0][0] and final_state[1][0]

贡献指南

打开贡献指南

调研方向

检查包含 attention_net 的 notebook 代码,并比较 issue 中展示的两种隐藏状态构造方式。验证 Bi-LSTM 的张量形状以及前向/后向状态的顺序,然后重新运行相关的 attention 路径,以确认修正后的计算按预期运行。

由索引模型根据 Issue 内容生成。

评估

技术栈
jupyter-notebook, python
领域
machine-learning
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。