Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Feedback about NLP From Scratch: Generating Names with a Character-Level RNN

オープン
#3,953 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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
平均マージ
4時間 39分
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pytorch/tutorials のほかの issue

pytorch/tutorials の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。