パーセプトロンから微分可能な MLP へ:層・重み・活性化関数
エージェント支援エンジニアリングチェック
前提条件
第 33 日の自動微分習得チェックと、検証済みの Value `backward()` セマンティクス。
学習目標
歴史的パーセプトロン(ステップ活性化)と微分可能ニューロン $z = \sum_i w_i x_i + b$、$a = \sigma(z)$ を区別し、XOR のような関数を表すには非線形活性化を持つ層の積み重ねが必要な理由を説明し、本日使う参照用 2-2-1 ネットワークの正確な構造を述べる。
手順
以下の概念分解を読み、計算の前に必ず予測してください。
パーセプトロンは $z = \sum_i w_i x_i + b$ を計算し、$z > 0$ なら $1$、そうでなければ $0$ を出力します。ステップ活性化により入出力写像は区分定数となり、勾配はほぼ至る所で $0$、折れ点では未定義です。したがって勾配ベースの学習では改善できません。微分可能ニューロンはステップを $\tanh$ のような滑らかな活性化に置き換えます。
多層パーセプトロン (MLP) は全結合層を積み重ねます。層 $l$ の各ニューロンは層 $l-1$ のすべての活性化を受け取ります。単一の線形ユニットは直線の決定境界しか引けず XOR を表現できません。非線形活性化を持つ 2 層以上なら可能です。
本日の参照ネットワーク N1:入力 $x=(2.0, -1.0)$。隠れニューロン $h_1$:重み $(0.5, -0.25)$、バイアス $0.1$、$\tanh$。隠れニューロン $h_2$:重み $(-0.5, 1.0)$、バイアス $-0.2$、$\tanh$。出力ニューロン $o$:重み $(1.0, -2.0)$、バイアス $0.3$、線形(活性化なし)。損失 $L = (o - y)^2$、目標 $y = 1.0$。
演習と予測記録
1. 計算を始める前に、$z_1$ と $z_2$ の符号を予測し、飽和に近い隠れニューロンがあるか判断してください。
2. N1 の学習可能パラメータを数え、重みとバイアスに分けてください。
3. ステップ活性化のパーセプトロンが勾配降下で学習できない理由を一文で述べてください。
4. $o$ が目標 $y = 1.0$ より上か下かを予測してください。
まず重み付き和を計算します:$z_1 = 0.5(2.0) + (-0.25)(-1.0) + 0.1$、$z_2 = -0.5(2.0) + 1.0(-1.0) + (-0.2)$。パラメータ数は各重みと各バイアスを別々に数えます。飽和の目安:$|z| \gtrsim 4$ で $\tanh$ は飽和します。
参考解答:
1. $z_1 = 1.0 + 0.25 + 0.1 = 1.35$(正・中程度・未飽和)。$z_2 = -1.0 - 1.0 - 0.2 = -2.2$(負・深い飽和でもない)。
2. 学習可能パラメータは 9 個:重み 6 個 ($(w_{11}, w_{12}), (w_{21}, w_{22}), (w_{o1}, w_{o2})$) とバイアス 3 個 ($b_1, b_2, b_o$)。
3. ステップ関数はほぼ至る所で平坦で、定義可能な点の導数は $0$、$z = 0$ では未定義。重みに有効な勾配が届きません。
4. $o = 1.0 \cdot \tanh(1.35) + (-2.0) \cdot \tanh(-2.2) + 0.3 \approx 0.874 + 1.951 + 0.3 = 3.126$ で、$y = 1.0$ を大きく上回ります。
学習者が $z = \sum w_i x_i + b$ と $a = \sigma(z)$ の式を書け、N1 の 9 個のパラメータを正しく数え、勾配ベースの学習に微分可能性が必要な理由を自分の言葉で説明できること。
公式ソースリソースと権利証跡
Neural Networks and Deep Learning: How the backpropagation algorithm works
該当セクション・タイムスタンプ: Sections: Perceptrons, Sigmoid neurons, The architecture of neural networks
検証バージョンと日付: Online book (Verified: 2026-10-30)
Clear four-equation derivation of backpropagation with scalar and matrix notation.
Matrix multiplication and the multivariable chain rule from Days 19-24.
All four backprop equations and derivations are self-contained within the lesson text.
比較対象候補リソースと選定評価 (2)
Comprehensive graduate reference, but heavier tensor notation than needed for first MLP derivations.
Modular computational graph view; used as secondary source on Days 35-36.
micrograd: A tiny scalar-valued autograd engine
該当セクション・タイムスタンプ: micrograd/engine.py: class Value (_backward closures and backward() topological sort); README 'Example usage'
検証バージョンと日付: Git commit master (Verified: 2026-10-30)
Minimal, readable implementation of scalar autograd and MLP layers directly matched to our project.
Python object-oriented programming and operator overloading from Day 31.
The local projects/autograd engine is runnable offline and matches micrograd semantics.
比較対象候補リソースと選定評価 (2)
Production scale, but too large and complex for tracing by hand in introductory lessons.
Vectorized autograd; micrograd's pure scalar model is pedagogical for hand backprop.