Feedback about NLP From Scratch: Generating Names with a Character-Level RNN
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- python
调研方向
从链接的“NLP From Scratch”教程页面开始,检查字符级 RNN 的实现及其训练示例。复现所报告的行为,评估提议的激活函数更改是否正确,并且仅在确认问题存在后更新教程,同时保留正常工作的训练过程和生成的样本。
由索引模型根据 Issue 内容生成。
描述
There is the following issue on this page: https://docs.pytorch.org/tutorials/intermediate/char_rnn_generation_tutorial.html.
There is no non-linearity wrapper while passing the hidden state onto the next iteration, and on output layer that predicts distribution. Results are coming relatively fine though, maybe because nn.LogSoftmax is implicitly acting as non-linearity. But for learning hidden states, its bad, $h_t$ is literally linear combination of $h_{t-1}$, all past $x$ s and $Cat$.
Simple Fix:
class RNN(nn.Module):
def __init__(self,C_in:int, C_hid:int, C_out:int):
super().__init__()
self.C_in = C_in
self.C_hid = C_hid
self.C_out = C_out
self.C_cat = data1.C_cat
self.i2h = nn.Linear(data1.C_cat + C_in + C_hid,C_hid)
self.i2o1 = nn.Linear(data1.C_cat + C_in + C_hid,C_out)
self.o12o2 = nn.Linear(C_out + C_hid,C_hid)
self.o22o3 = nn.Linear(C_hid, C_out)
self.tanh = nn.Tanh()
self.todist = nn.LogSoftmax(dim=1)
def forward(self,x_C:tensor, x_X:tensor, x_H:tensor):
# Inputs = (B=1,C_cat), (B=1, C_in), (B=1,C_out),
# Output = (B=1, C_out), (B=1,C_hid)
x = torch.cat((x_C,x_X,x_H),dim=1)
h = self.tanh(self.i2h(x))
x = self.i2o1(x)
x = torch.cat((x,h),dim=1)
x = self.tanh(self.o12o2(x))
x = self.o22o3(x)
return self.todist(x), h
Edit1: nn.tanh 's range is between $[-1,1]$. Compressing logits before softmax can really impact the result. Using one more layer before projection gave me similar error of 2.2127 , and nice samples.
Thank you.
- 主要语言
- Python
- 星标
- 9.3k
- 派生
- 4.4k
- 平均合并
- 1 天 21 小时
- 30 天内合并 PR
- 4
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytorch/tutorials 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 70/100
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 1/5 1 小时以内 新手友好度 78/100
-
难度 1/5 1 小时以内 新手友好度 78/100
查看 pytorch/tutorials 的全部 Issue
相似的 Issue
-
good first issue
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 88/100
vllm-project/vllm-metal#822 ·
维护者通常 1 天内回复
-
vector-store
难度 1/5 1-3 小时 新手友好度 90/100
维护者通常 1 天内回复
-
[Bug]: chunk_span_bounds and _validated_chunk_spans reject Pydantic models ChunkSpan and AudioFile未关闭
难度 2/5 1-3 小时 新手友好度 78/100
BasedHardware/omi#19047 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复