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

Feedback about What is torch.nn really?

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

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

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

  • #3667 @patrocinio による — マージされずにクローズ

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python, pytorch
領域
documentation

調査の方向性

リンク先の nn_tutorial.html ページを開き、「Neural net from scratch (without torch.nn)」セクション、特に pre-training と final loss の評価を確認してください。トレーニングループを通じて xb と yb がどのように変化するかを追跡し、そのうえで、比較に一貫した評価用バッチを使用するか、テストデータセットを明示的に使用するようにチュートリアルを更新してください。表示される loss と accuracy の例に整合性が保たれていることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

core

There is the following issue on this page: https://docs.pytorch.org/tutorials/beginner/nn_tutorial.html

In the section "Neural net from scratch (without torch.nn)" there is a pre-training loss function evaluation on a batch of 64 instances,

yb = y_train[0:bs]
print(loss_func(preds, yb))

then training is performed (comments my own)

for epoch in range(epochs):
    for i in range((n - 1) // bs + 1):
        #         set_trace()
        start_i = i * bs
        end_i = start_i + bs
        xb = x_train[start_i:end_i] # note that xb gets redefined
        yb = y_train[start_i:end_i] # note that yb gets redefined
        pred = model(xb)
        loss = loss_func(pred, yb)

        loss.backward()
        with torch.no_grad():
            weights -= weights.grad * lr
            bias -= bias.grad * lr
            weights.grad.zero_()
            bias.grad.zero_()

and the loss function is evaluated again to demonstrate a reduction in loss.

print(loss_func(model(xb), yb), accuracy(model(xb), yb))

The final evaluation is not applied to the same data as the first though. Both invoke xb and yb, but xb and yb in the pre-training evaluation are the first 64 instances from the set, during training these variables are updated with subsequent batches and the final evaluation is performed on the final batch.

Pre and post-training evaluations should be performed on the same batch, either the original 64 instances from the first training batch, or (if the intent is to demonstrate generalization loss) the test dataset.

cc @albanD @jbschlosser

主要言語
Python
スター
9.4k
フォーク
4.4k
平均マージ
3日 5時間
マージ済み PR(30日)
4

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

pytorch/tutorials のほかの issue

pytorch/tutorials の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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