23 / 90

第 23 日:行列積、shape 台帳、転置と逆行列

行列積を線形写像の合成として計算し、すべての積に明示的な (m x k)(k x n) -> m x n の shape 台帳を付け、転置・単位行列・逆行列の直感を育てる。すべての積をモデル内の重み行列に結びつける。各活動で予測、観察、復習、回復を480分の台帳に記録する。

数学とアルゴリズム基礎 480 アクティブ分(8時間の集中学習)
01 120 分

線形写像の合成としての行列積

予測と観察の証跡を記録した後のみ支援を利用できる。

前提条件

第 22 日を完了すること。行列・ベクトル積が不安なら記載の回復リンクを使う。

学習目標

行列積を行×列の内積として成分ごとに計算し、A*B を「まず B を適用し、次に A を適用する」合成写像として解釈し、行列積が非可換であることを実証する。

手順

成分 (A*B)_ij は A の行 i と B の列 j の内積である。幾何学的には (A*B)*x = A*(B*x):積の行列は内側の写像を先に適用するので、合成は右から左に読む。合成は順序に依存するため、一般に A*B と B*A は異なる。

演習と予測記録

A = [[1,2],[3,4]]、B = [[0,1],[1,0]](B はベクトルの成分を入れ替える)とする。計算前に両方の積を予測せよ:(a) A*B;(b) B*A。両者は等しいか?

独立習得基準

両方の積を正しく計算し、右から左への合成の読み方を説明し、2つの順序が幾何学的に異なる理由(入れ替えてから写像 vs 写像してから入れ替え)を1つ挙げられる。

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

linking 3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions No video, audio, transcript or frame redistribution permitted

Essence of Linear Algebra

著者・提供機関: Grant Sanderson (3Blue1Brown) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Chapter 4: Matrix multiplication as composition

検証バージョンと日付: 2016-2023 (Verified: 2026-10-30)

選定理由:

Unequaled geometric and visual intuition for vectors, linear transformations, matrix multiplication, and inverses before tensor operations.

ソース前提知識:

High-school coordinate geometry

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

Geometric explanations, worked formulas, and coordinate exercises are fully provided as original lesson text.

比較対象候補リソースと選定評価 (2)
MIT OCW 18.06 Linear Algebra (Prof. Gilbert Strang) ↗ compared_alternative [CC BY-NC-SA 4.0]

Established textbook/lecture approach, strong mathematical rigor alongside 3Blue1Brown visual intuition.

Linear Algebra Done Right (Sheldon Axler) ↗ compared_rejected_for_curriculum [CC BY-NC (4th edition, Open Access)]

Theoretical determinant-free proof structure is mathematically elegant but less aligned with computational tensor engineering.

linking CC BY-NC-SA 4.0 noncommercial share-alike

18.06 Linear Algebra (Prof. Gilbert Strang)

著者・提供機関: MIT OpenCourseWare (Prof. Gilbert Strang) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Lecture 3: matrix multiplication and its four viewpoints

検証バージョンと日付: Spring 2010 (Verified: 2026-10-30)

選定理由:

Established row-picture and column-picture treatment of linear systems, matrix products, and invertibility; rigorous complement to the 3Blue1Brown visual series.

ソース前提知識:

High-school algebra and coordinate geometry

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

All row/column-picture derivations and worked examples are written as original lesson text and run offline.

比較対象候補リソースと選定評価 (3)
3Blue1Brown: Essence of Linear Algebra ↗ compared_selected_for_days_22_24 [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Selected as co-primary: geometric visualizations paired with Strang's algebraic rigor.

Linear Algebra Done Right (Sheldon Axler) ↗ compared_rejected_for_curriculum [CC BY-NC (4th edition, Open Access)]

Determinant-free theoretical treatment is elegant but further from the computational shape accounting required here.

Immersive Linear Algebra (online interactive book) ↗ compared_rejected_for_days_22_24 [Free online (site terms; no OSI/CC license declared)]

Interactive figures are attractive, but the absence of a declared open license makes rights disposition unclear; kept out of the resource set.

02 120 分

shape 台帳:積の次元を予測する

独立演習:結果確認前に予測を記録し、証跡を記した後のみ支援を利用。

前提条件

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

学習目標

すべての積に書面の shape 台帳を付ける:(m x k)(k x n) -> (m x n)。内側の次元が一致しなければならず、不一致は暗記ではなく予測すべきエラーである。

手順

両方の shape を書き、内側の次元が一致するか確認し、1成分も計算する前に出力 shape を予測する。同じ台帳をモデルのブロックにも適用する:MLP は shape (batch x d_model) の X に W1 (d_model x d_ff)、続いて W2 (d_ff x d_model) を掛ける。各重み行列はモデル内部の階数2のテンソルである。

演習と予測記録

shape と値を予測せよ。(a) C (2x3) = [[1,0,2],[-1,3,1]] と D (3x2) = [[3,1],[2,1],[1,0]] の積:出力 shape は?4成分すべてを計算せよ。(b) トランスフォーマー MLP の台帳:X (32 x 768) * W1 (768 x 3072)、続けて * W2 (3072 x 768)。(c) (2x3)(2x3) は有効か?

独立習得基準

計算前にすべての出力 shape を予測し、C*D = [[5,1],[4,2]] を正確に再現し、「内側の次元が一致しなければならない」という規則を失敗例付きで述べられる。

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

linking CC BY-NC-SA 4.0 noncommercial share-alike

18.06 Linear Algebra (Prof. Gilbert Strang)

著者・提供機関: MIT OpenCourseWare (Prof. Gilbert Strang) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Lecture 3: (m x k)(k x n) -> m x n dimension rule

検証バージョンと日付: Spring 2010 (Verified: 2026-10-30)

選定理由:

Established row-picture and column-picture treatment of linear systems, matrix products, and invertibility; rigorous complement to the 3Blue1Brown visual series.

ソース前提知識:

High-school algebra and coordinate geometry

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

All row/column-picture derivations and worked examples are written as original lesson text and run offline.

比較対象候補リソースと選定評価 (3)
3Blue1Brown: Essence of Linear Algebra ↗ compared_selected_for_days_22_24 [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Selected as co-primary: geometric visualizations paired with Strang's algebraic rigor.

Linear Algebra Done Right (Sheldon Axler) ↗ compared_rejected_for_curriculum [CC BY-NC (4th edition, Open Access)]

Determinant-free theoretical treatment is elegant but further from the computational shape accounting required here.

Immersive Linear Algebra (online interactive book) ↗ compared_rejected_for_days_22_24 [Free online (site terms; no OSI/CC license declared)]

Interactive figures are attractive, but the absence of a declared open license makes rights disposition unclear; kept out of the resource set.

linking BSD 3-Clause License

NumPy Reference: The N-dimensional array (ndarray)

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

該当セクション・タイムスタンプ: ndarray.shape semantics and matrix product dimensions

検証バージョンと日付: NumPy 2.x documentation (Verified: 2026-10-30)

選定理由:

Primary semantics for ndarray shape, strides, reshape orders, and view-versus-copy behavior used in tensor memory accounting.

ソース前提知識:

Basic Python

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

Shape, stride, and memory-ledger exercises are fully explained with local runnable examples.

比較対象候補リソースと選定評価 (2)
PyTorch Documentation: torch.Tensor ↗ compared_alternative [Modified BSD]

Equivalent tensor semantics in the framework used later in the curriculum; NumPy reference selected to keep Days 22-24 dependency-free.

NumPy User Guide: Broadcasting ↗ compared_selected_for_days_22_24 [BSD 3-Clause License]

Selected as co-primary for Day 24: the broadcasting rules page pairs with the ndarray attribute reference.

03 120 分

転置・単位行列・逆行列の直感

予測と観察の証跡を記録した後のみ支援を利用できる。

前提条件

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

学習目標

転置を対角線に関する鏡映として (A*B)^T = B^T * A^T とともに使い、単位行列 I を「何もしない」写像として扱い、A^-1 を A を打ち消す写像として読む——逆行列は A が何も潰さないときだけ存在する。

手順

転置は行と列を入れ替える:(A^T)_ij = A_ji。積の転置は順序が逆になる。単位行列 I は I*x = x を満たす。逆行列 A^-1 は A*A^-1 = I を満たす。ゼロでない零空間を持つ行列はある方向をゼロに潰すので、逆行列はそれを復元できない。2x2 行列では det = ad - bc = 0 がこの潰れの兆候である。

演習と予測記録

(a) 前の活動の C*D = [[5,1],[4,2]] で (C*D)^T を予測し、D^T * C^T に等しいか検証せよ。(b) A = [[2,1],[1,1]] について A * A^-1 を計算し A^-1 = [[1,-1],[-1,2]] を検証せよ。(c) S = [[1,2],[2,4]]:det(S) を求め、S*x = 0 となる非ゼロ x を見つけよ。S は逆行列を持つか?

独立習得基準

A * A^-1 = I を成分ごとに検証し、転置の積規則を数値で実証し、S*(2,-1) = 0 を使って「特異とはある方向が破壊されること」を説明できる。

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

linking 3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions No video, audio, transcript or frame redistribution permitted

Essence of Linear Algebra

著者・提供機関: Grant Sanderson (3Blue1Brown) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Chapters 5-6: determinants and inverse matrices

検証バージョンと日付: 2016-2023 (Verified: 2026-10-30)

選定理由:

Unequaled geometric and visual intuition for vectors, linear transformations, matrix multiplication, and inverses before tensor operations.

ソース前提知識:

High-school coordinate geometry

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

Geometric explanations, worked formulas, and coordinate exercises are fully provided as original lesson text.

比較対象候補リソースと選定評価 (2)
MIT OCW 18.06 Linear Algebra (Prof. Gilbert Strang) ↗ compared_alternative [CC BY-NC-SA 4.0]

Established textbook/lecture approach, strong mathematical rigor alongside 3Blue1Brown visual intuition.

Linear Algebra Done Right (Sheldon Axler) ↗ compared_rejected_for_curriculum [CC BY-NC (4th edition, Open Access)]

Theoretical determinant-free proof structure is mathematically elegant but less aligned with computational tensor engineering.

linking CC BY-NC-SA 4.0 noncommercial share-alike

18.06 Linear Algebra (Prof. Gilbert Strang)

著者・提供機関: MIT OpenCourseWare (Prof. Gilbert Strang) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Lecture 3: inverses and transposes; Lecture 4: factorization

検証バージョンと日付: Spring 2010 (Verified: 2026-10-30)

選定理由:

Established row-picture and column-picture treatment of linear systems, matrix products, and invertibility; rigorous complement to the 3Blue1Brown visual series.

ソース前提知識:

High-school algebra and coordinate geometry

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

All row/column-picture derivations and worked examples are written as original lesson text and run offline.

比較対象候補リソースと選定評価 (3)
3Blue1Brown: Essence of Linear Algebra ↗ compared_selected_for_days_22_24 [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Selected as co-primary: geometric visualizations paired with Strang's algebraic rigor.

Linear Algebra Done Right (Sheldon Axler) ↗ compared_rejected_for_curriculum [CC BY-NC (4th edition, Open Access)]

Determinant-free theoretical treatment is elegant but further from the computational shape accounting required here.

Immersive Linear Algebra (online interactive book) ↗ compared_rejected_for_days_22_24 [Free online (site terms; no OSI/CC license declared)]

Interactive figures are attractive, but the absence of a declared open license makes rights disposition unclear; kept out of the resource set.

04 120 分

独立習得:積・shape・可逆性

独立習得チェック(AI支援なし)。

前提条件

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

学習目標

支援なしで 2x2 の積を計算し、アテンションの shape 台帳を予測し、与えられた行列が可逆かを判定する。間違いがあれば回復メモを書く。

手順

閉書で行う:まず予測、次に計算、最後に比較。掛ける前にすべての shape を記録する。意外な結果が出たら、どの規則を誤用したかを記録し、回復リンクをメモする。

演習と予測記録

課題:(a) P = [[1,1],[0,1]]、M = [[2,0],[1,1]] で P*M;(b) アテンション台帳:Q (8 x 64) に K^T(K は (8 x 64))を掛け、softmax、続けて V (8 x 64) を掛ける。各出力 shape を予測せよ;(c) [[2,4],[1,2]] は可逆か?

独立習得基準

すべての予測を無支援で検証済み。(8x8) のアテンションスコア shape と特異性の議論を、完全な shape 台帳とともに自分の言葉で書けている。

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

linking CC BY-NC-SA 4.0 noncommercial share-alike

18.06 Linear Algebra (Prof. Gilbert Strang)

著者・提供機関: MIT OpenCourseWare (Prof. Gilbert Strang) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Lecture 1-3 problem sets on products and inverses

検証バージョンと日付: Spring 2010 (Verified: 2026-10-30)

選定理由:

Established row-picture and column-picture treatment of linear systems, matrix products, and invertibility; rigorous complement to the 3Blue1Brown visual series.

ソース前提知識:

High-school algebra and coordinate geometry

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

All row/column-picture derivations and worked examples are written as original lesson text and run offline.

比較対象候補リソースと選定評価 (3)
3Blue1Brown: Essence of Linear Algebra ↗ compared_selected_for_days_22_24 [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Selected as co-primary: geometric visualizations paired with Strang's algebraic rigor.

Linear Algebra Done Right (Sheldon Axler) ↗ compared_rejected_for_curriculum [CC BY-NC (4th edition, Open Access)]

Determinant-free theoretical treatment is elegant but further from the computational shape accounting required here.

Immersive Linear Algebra (online interactive book) ↗ compared_rejected_for_days_22_24 [Free online (site terms; no OSI/CC license declared)]

Interactive figures are attractive, but the absence of a declared open license makes rights disposition unclear; kept out of the resource set.

linking 3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions No video, audio, transcript or frame redistribution permitted

Essence of Linear Algebra

著者・提供機関: Grant Sanderson (3Blue1Brown) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Chapters 4-6 review

検証バージョンと日付: 2016-2023 (Verified: 2026-10-30)

選定理由:

Unequaled geometric and visual intuition for vectors, linear transformations, matrix multiplication, and inverses before tensor operations.

ソース前提知識:

High-school coordinate geometry

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

Geometric explanations, worked formulas, and coordinate exercises are fully provided as original lesson text.

比較対象候補リソースと選定評価 (2)
MIT OCW 18.06 Linear Algebra (Prof. Gilbert Strang) ↗ compared_alternative [CC BY-NC-SA 4.0]

Established textbook/lecture approach, strong mathematical rigor alongside 3Blue1Brown visual intuition.

Linear Algebra Done Right (Sheldon Axler) ↗ compared_rejected_for_curriculum [CC BY-NC (4th edition, Open Access)]

Theoretical determinant-free proof structure is mathematically elegant but less aligned with computational tensor engineering.