💡 [REQUEST] - Clarification of requires_grad about beginner/nn_tutorial.html
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
- #3717 @FlightVin による — マージされずにクローズ
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 55/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
調査の方向性
beginner/nn_tutorial.html のソースを開き、「Neural Net from Scratch without torch.nn」セクションを見つけます。重みとバイアスに関する既存のコメントを更新し、初期化の計算後まで重みに対する requires_grad の設定を遅らせる理由を説明します。レンダリングされたチュートリアルで leaf と non-leaf の違いが明確になった時点で完了です。
索引モデルが issue の本文から書いたものです。
説明
🚀 Describe the improvement or the new tutorial
It was challenging for me to initially grasp why requires_grad was done after weights, but in the same line as bias under https://docs.pytorch.org/tutorials/beginner/nn_tutorial.html#neural-net-from-scratch-without-torch-nn
At first glance, the code looks inconsistent:
weightsinitialization is split into two lines.biasinitialization is done in one line.
The Logic Gap
The tutorial currently explains that we do it, but not exactly why the distinction exists between these two specific variables.
- The Bias is created using a factory function (
torch.zeros) with no subsequent mathematical operations. It is born as a "Leaf Node" (a source parameter). - The Weights involve a mathematical operation (
/ math.sqrt(...)). If we setrequires_grad=Trueinsidetorch.randn(), PyTorch records the division as a computational step. The resultingweightsvariable becomes a non-leaf node (a calculated outcome), which the optimizer cannot update.
Proposed Improvement
I propose modifying the comment block to explicitly mention that requires_grad must be deferred until after the initialization math is complete to preserve the tensor as a trainable parameter (Leaf Node).
Existing tutorials on this topic
- https://docs.pytorch.org/tutorials/beginner/nn_tutorial.html
- https://docs.pytorch.org/tutorials/beginner/nn_tutorial.html#neural-net-from-scratch-without-torch-nn
Additional context
- 主要言語
- Python
- スター
- 9.5k
- フォーク
- 4.5k
- 平均マージ
- 1日 20時間
- マージ済み PR(30日)
- 2
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytorch/tutorials のほかの issue
-
module: vulkan
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
Feedback about Datasets & DataLoaders対応中かも @hippi345 が 47 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 2 日以内に返信
-
💡 [REQUEST] - Add model.eval() after loading the mdoel対応中かも @Justee21 が 71 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
[BUG] Captum tutorial fails when visualize_image_attr() receives None for original_image対応中かも @manjirisharma が 41 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
pytorch/tutorials#3963 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
[BUG] - Incorrect ResNet18 preprocessing in Captum tutorial対応中かも @austxu が 130 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 2 日以内に返信
pytorch/tutorials の issue をすべて見る
似ている issue
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
MakazhanAlpamys/Soup#3589 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
ClickHouse/clickhouse-connect#1266 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
biosustain/growthcurves_app#89 ·
メンテナーはふだん 1 日以内に返信
-
`LogProxyConsumer._on_relation_departed` raises `APIError` when the promtail service does not existオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
canonical/loki-k8s-operator#695 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信