42 / 90

第 42 日:損失、訓練の規律、週次総復習

softmax 確率を交差エントロピー損失に変え、固定分割と固定シードによる規律ある訓練ループを観察し、過学習と数値不安定の反例に正直に向き合い、独立した想起評価で週を締めくくる。復習時間は 480 分の台帳に算入される。

モデルと訓練 480 分の能動学習時間(8 時間の集中学習)
01 120 分

交差エントロピー損失:確率からスカラー驚き度へ

Agent支援エンジニアリング確認

前提条件

第 41 日の順伝播と softmax、自然対数。

学習目標

負の対数尤度損失を定義し、例題分布で計算し、一様ベースラインと比較して解釈する。

手順

必須作業:ターゲットインデックス t の損失は L = -ln p_t。昨日の順伝播は文脈 ('a','b')(真の次シンボルは 'c'、インデックス 3)に対して p = [0.229291, 0.209107, 0.306433, 0.255169] を出力した。L を計算し、一様ベースライン ln(4) = 1.386294 と比較して、このモデルが偶然よりましかどうか判断する。任意作業:log2 に切り替えて L をビットで表す。

演習と予測記録

1. L = -ln(0.255169) = ?
2. 3 クラスのロジット z = [1.0, 0.5, -0.5]、ターゲットインデックス 0 で、softmax 確率と NLL を計算する。
3. この例でのパープレキシティ exp(L) の意味は?

独立習得基準

両方の損失を小数 4 桁以上で計算し、一様ベースラインとの比較を述べ、パープレキシティを実効語彙サイズとして解釈できる。

公式ソースリソースと権利証跡

linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

makemore: Character-level language models on names.txt

著者・提供機関: Andrej Karpathy | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Loss computation segment: negative log-likelihood over the minibatch

検証バージョンと日付: Repository state verified 2026-10-30; lecture published 2022

選定理由:

Standard beginner walkthrough of the Bengio-style MLP language model; the MIT-licensed reference implementation pairs with a stepwise derivation that matches the Days 40-42 worked numbers exactly.

ソース前提知識:

Python basics, matrix multiplication, and the Day 37-39 tokenization and n-gram context

安全フォールバック(オフライン回復性):

All forward-pass arithmetic, shapes, parameter counts, and loss values are reproduced as original hand-worked examples in the lesson text; no video, subtitle, or transcript is required.

比較対象候補リソースと選定評価 (3)
Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

linking JMLR open access (author-retained copyright)

A Neural Probabilistic Language Model

著者・提供機関: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Section 2 (training criterion: maximizing the log-likelihood, equivalently minimizing NLL)

検証バージョンと日付: JMLR Volume 3 (2003); verified 2026-10-30

選定理由:

The original paper introducing jointly learned word feature vectors and the neural probabilistic language model; grounds the curriculum's embedding and MLP derivations in the primary literature.

ソース前提知識:

Probability basics and linear algebra

安全フォールバック(オフライン回復性):

Every worked derivation in the lessons is self-contained and offline-complete; the paper is further reading only.

比較対象候補リソースと選定評価 (3)
Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

Selected jointly: Makemore reproduces this architecture at character scale with MIT-licensed code; the paper supplies the original formalism and the n-gram comparison framing.

Strong textbook coverage of n-grams through neural LMs; kept as secondary reading because the primary derivation follows the original paper's notation.

Foundational for embedding geometry but trains on context-prediction objectives rather than the full next-token probabilistic model studied this week; revisited in later representation blocks.

02 120 分

訓練ループの観察:固定分割での損失・勾配・更新

独立習得確認

前提条件

前の活動を完了すること。詰まった場合は記載の回復リンクを使う。

学習目標

1 回の訓練ステップ(順伝播 → 損失 → 逆伝播 → 更新)と固定 train/dev/test 分割およびシードの役割を記述する。損失変化の方向を予測するが、閾値は約束しない。

手順

必須作業:第 34-36 日の勾配ステップを思い出す。1 回の反復は (文脈, ターゲット) ペアのミニバッチを取り、順伝播を実行し、NLL を平均し、逆伝播し、全パラメータを p <- p - lr * dL/dp で更新する。予測する損失曲線の形を記録し、固定された 80/10/10 の train/dev/test 分割と固定シードが比較に何を保証するか説明する。任意作業:学習率が大きすぎると曲線に何が起きるか予測する。

演習と予測記録

1. 1 回の訓練ステップの 4 段階を順に挙げる。
2. train 損失が下がり続けるのに dev 損失が上がる場合、何を示すか?
3. 固定シードと分割が 2 つのモデル変種を正直に比較可能にする理由は?

独立習得基準

学習者が 4 段階を順に並べ、dev 上昇の説明として過学習を挙げ、固定シード/分割が比較可能性を与えると述べられる。損失保証を捏造しない。

公式ソースリソースと権利証跡

linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

makemore: Character-level language models on names.txt

著者・提供機関: Andrej Karpathy | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Training loop segment: minibatch SGD, learning-rate schedule, train/dev split discipline

検証バージョンと日付: Repository state verified 2026-10-30; lecture published 2022

選定理由:

Standard beginner walkthrough of the Bengio-style MLP language model; the MIT-licensed reference implementation pairs with a stepwise derivation that matches the Days 40-42 worked numbers exactly.

ソース前提知識:

Python basics, matrix multiplication, and the Day 37-39 tokenization and n-gram context

安全フォールバック(オフライン回復性):

All forward-pass arithmetic, shapes, parameter counts, and loss values are reproduced as original hand-worked examples in the lesson text; no video, subtitle, or transcript is required.

比較対象候補リソースと選定評価 (3)
Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

linking JMLR open access (author-retained copyright)

A Neural Probabilistic Language Model

著者・提供機関: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Sections 3-4 (parameter optimization and experimental methodology)

検証バージョンと日付: JMLR Volume 3 (2003); verified 2026-10-30

選定理由:

The original paper introducing jointly learned word feature vectors and the neural probabilistic language model; grounds the curriculum's embedding and MLP derivations in the primary literature.

ソース前提知識:

Probability basics and linear algebra

安全フォールバック(オフライン回復性):

Every worked derivation in the lessons is self-contained and offline-complete; the paper is further reading only.

比較対象候補リソースと選定評価 (3)
Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

Selected jointly: Makemore reproduces this architecture at character scale with MIT-licensed code; the paper supplies the original formalism and the n-gram comparison framing.

Strong textbook coverage of n-grams through neural LMs; kept as secondary reading because the primary derivation follows the original paper's notation.

Foundational for embedding geometry but trains on context-prediction objectives rather than the full next-token probabilistic model studied this week; revisited in later representation blocks.

03 120 分

反例:過学習、数値不安定、bigram ベースライン

Agent支援エンジニアリング確認

前提条件

前の活動を完了すること。詰まった場合は記載の回復リンクを使う。

学習目標

正直な反例を作る:小データでの暗記、softmax の exp オーバーフロー、未訓練ネットワークに勝てる単純なカウントベースライン。

手順

必須作業:3 つの反例。(1) 暗記:4 シンボルの玩具コーパスで、モデルは train NLL を 0 に近づけられるのに dev NLL は ln(4) = 1.386294 付近に留まる。(2) 不安定性:ロジット [1000,999,998] では非シフト exp が float64 でオーバーフローするが、シフト版 softmax は [0.665241, 0.244728, 0.090031]。(3) ベースライン:コーパスで 'b' の後に 'c' が 4 回中 3 回来るなら、bigram は p(c|b) = 0.75 を与える。任意作業:訓練済み MLP でさえ bigram に負ける状況を 1 つ述べる。

演習と予測記録

1. ロジット [1000,999,998] のシフト版 softmax 分布を再現する。
2. p(c|b) = 0.75 の場合と、未出現ペア p = 0.25 の場合の bigram NLL を計算する。
3. 未訓練 MLP と bigram ベースラインを比較する正直な一文を書く。

独立習得基準

3 つの反例すべてを正しい数値で再現し、暗記の限界と真の優位性の条件の両方を含む正直な比較文を書ける。

公式ソースリソースと権利証跡

linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

makemore: Character-level language models on names.txt

著者・提供機関: Andrej Karpathy | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Overfitting and split evaluation segments; comparison with the bigram counting baseline

検証バージョンと日付: Repository state verified 2026-10-30; lecture published 2022

選定理由:

Standard beginner walkthrough of the Bengio-style MLP language model; the MIT-licensed reference implementation pairs with a stepwise derivation that matches the Days 40-42 worked numbers exactly.

ソース前提知識:

Python basics, matrix multiplication, and the Day 37-39 tokenization and n-gram context

安全フォールバック(オフライン回復性):

All forward-pass arithmetic, shapes, parameter counts, and loss values are reproduced as original hand-worked examples in the lesson text; no video, subtitle, or transcript is required.

比較対象候補リソースと選定評価 (3)
Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

linking JMLR open access (author-retained copyright)

A Neural Probabilistic Language Model

著者・提供機関: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Section 4 (comparison with n-gram baselines and generalization discussion)

検証バージョンと日付: JMLR Volume 3 (2003); verified 2026-10-30

選定理由:

The original paper introducing jointly learned word feature vectors and the neural probabilistic language model; grounds the curriculum's embedding and MLP derivations in the primary literature.

ソース前提知識:

Probability basics and linear algebra

安全フォールバック(オフライン回復性):

Every worked derivation in the lessons is self-contained and offline-complete; the paper is further reading only.

比較対象候補リソースと選定評価 (3)
Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

Selected jointly: Makemore reproduces this architecture at character scale with MIT-licensed code; the paper supplies the original formalism and the n-gram comparison framing.

Strong textbook coverage of n-grams through neural LMs; kept as secondary reading because the primary derivation follows the original paper's notation.

Foundational for embedding geometry but trains on context-prediction objectives rather than the full next-token probabilistic model studied this week; revisited in later representation blocks.

04 120 分

週次総復習:独立した想起とエンドツーエンド評価

独立習得確認

前提条件

活動 42-01 から 42-03 を完了し、必要に応じて第 40-41 日を復習すること。

学習目標

第 40-42 日のパイプライン全体を無援助で想起し、未使用文脈の損失を再計算し、欠落した概念ごとに回復リンクを記録する。

手順

必須作業:教科書を閉じる。すべての形状を付けて、インデックス → C の行 → 連結 → W1/b1 → tanh → W2/b2 → softmax → NLL のパイプラインをスケッチする。次に文脈 ('b','a')、真の次シンボル 'a'(インデックス 1)について、第 41 日の確率を使って損失を計算する。知識チェックに答える。欠落があれば、第 40 日・第 41 日・回復リンクの第 35 日のどれを再訪するか記録する。任意作業:V=27 の一様ベースラインを再導出する。

演習と予測記録

1. ターゲットインデックス 1 で p = [0.290410, 0.237875, 0.220627, 0.251087] の損失。
2. 記憶だけで極小モデルのパラメータ台帳(合計 39)を再構築する。
3. ニューラル言語モデルが bigram より正直に優れるための 2 条件を述べる。

客観的理解度チェック:損失・訓練・正直な比較

以下の設問に解答して理解度を確認してください。提出前に利用した補助条件を誠実に申告してください。

申告補助条件

注記: AI不使用は誠実な申告条件であり、監視や強制検知ではありません。

1.

4 シンボル課題で NLL が ln(4) = 1.386294 を下回るモデルは、平均的に:

2.

V=4 課題で train NLL が 0 付近、dev NLL が 1.39 付近の場合、最も可能性が高いのは:

3.

2 つのモデルを比較する前に乱数シードと train/dev/test 分割を固定する理由は?

解答根拠と履歴

    独立習得基準

    無援助で損失 1.436009 と台帳再構築、正しい形状のパイプラインスケッチ、ベースラインを上回るための正直な条件を述べ、ギャップには回復リンクを指名できる。

    公式ソースリソースと権利証跡

    linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

    makemore: Character-level language models on names.txt

    著者・提供機関: Andrej Karpathy | オリジナル出所URL ↗

    該当セクション・タイムスタンプ: Complete makemore MLP lecture: embedding lookup through loss evaluation

    検証バージョンと日付: Repository state verified 2026-10-30; lecture published 2022

    選定理由:

    Standard beginner walkthrough of the Bengio-style MLP language model; the MIT-licensed reference implementation pairs with a stepwise derivation that matches the Days 40-42 worked numbers exactly.

    ソース前提知識:

    Python basics, matrix multiplication, and the Day 37-39 tokenization and n-gram context

    安全フォールバック(オフライン回復性):

    All forward-pass arithmetic, shapes, parameter counts, and loss values are reproduced as original hand-worked examples in the lesson text; no video, subtitle, or transcript is required.

    比較対象候補リソースと選定評価 (3)
    Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

    The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

    Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

    Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

    3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

    Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

    linking JMLR open access (author-retained copyright)

    A Neural Probabilistic Language Model

    著者・提供機関: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | オリジナル出所URL ↗

    該当セクション・タイムスタンプ: Sections 1-4 (complete model and evaluation overview)

    検証バージョンと日付: JMLR Volume 3 (2003); verified 2026-10-30

    選定理由:

    The original paper introducing jointly learned word feature vectors and the neural probabilistic language model; grounds the curriculum's embedding and MLP derivations in the primary literature.

    ソース前提知識:

    Probability basics and linear algebra

    安全フォールバック(オフライン回復性):

    Every worked derivation in the lessons is self-contained and offline-complete; the paper is further reading only.

    比較対象候補リソースと選定評価 (3)
    Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

    Selected jointly: Makemore reproduces this architecture at character scale with MIT-licensed code; the paper supplies the original formalism and the n-gram comparison framing.

    Strong textbook coverage of n-grams through neural LMs; kept as secondary reading because the primary derivation follows the original paper's notation.

    Foundational for embedding geometry but trains on context-prediction objectives rather than the full next-token probabilistic model studied this week; revisited in later representation blocks.