Skip to main content

Stephen Welch : なぜディープラーニングは驚くほどうまくいくのか

· 85 min read

前置き

深層学習に関する解説動画は無数にあるが、今回の動画は直感的な理解を促すものとなっている。つまり抽象度がそれほど高くないので理解した気になれる動画。

以下の要約内容をざっと頭に入れてから動画を見ると(英語の聴き取りができずとも)、納得できる筈。

概要

AI

なぜディープラーニングは驚くほどうまくいくのか

このビデオは、‌‌深層学習‌‌がどのように機能するか、特に‌‌ニューラルネットワーク‌‌が複雑な境界線を学習する能力について詳しく説明しています。

‌ユニバーサル近似定理‌‌を導入し、十分な数のニューロンがあれば、2層のネットワークがどんな連続関数でも表現できることを示していますが、実際には‌‌勾配降下法‌‌ではそのような解決策を見つけるのが難しい場合があります。

代わりに、より多くの層を持つ‌‌深いネットワーク‌‌が、少ないニューロン数でより複雑なパターンを学習できることが、‌‌ReLU活性化関数‌‌による層ごとの幾何学的変換を通じて解説されています。また、このビデオは‌‌Welch Labs‌‌という教育コンテンツ作成者の個人史と、その活動の資金調達の課題についても触れています。

目次

  1. 前置き
  2. 概要
  3. 音声対話
  4. 詳細
    1. 1. ユニバーサル近似定理とその限界
    2. 2. 深層ネットワークの優位性
    3. 3. ニューラルネットワーク研究の進化と教育への貢献
    4. 結論
  5. 普遍的近似定理
    1. 普遍的近似定理の定義とその保証
    2. 理論と実践のギャップ
    3. ディープネットワークの利点と効率性
  6. ニューラルネットワークの幾何学的解釈
    1. 1. 浅い(2層)ニューラルネットワークの幾何学的解釈
    2. 2. 深い(多層)ニューラルネットワークの幾何学的解釈
  7. 浅いネットワークと深いネットワークの対比
    1. ワイドネットワーク(浅い2層ニューラルネットワーク)の幾何学的解釈と限界
    2. ディープネットワーク(多層ニューラルネットワーク)の幾何学的解釈と優位性
    3. ワイドネットワークとディープネットワークの比較
  8. 学習プロセスと課題
    1. 学習プロセス
    2. 学習の課題と限界
  9. 情報源
    1. 動画概要欄

音声対話

詳細

AI

ブリーフィングドキュメント:ディープラーニングが「不合理なほど」うまく機能する理由

このブリーフィングドキュメントは、提供されたソース「Why Deep Learning Works Unreasonably Well.en.txt」の主要テーマと最も重要なアイデアまたは事実をレビューすることを目的としています。特に、ニューラルネットワークが複雑な関数を近似し、深層ネットワークが浅いネットワークよりも効率的である理由に焦点を当てます。

1. ユニバーサル近似定理とその限界

  • 定理の内容: 1989年にジョージ・シバンコによって証明されたユニバーサル近似定理は、「複雑な関数、例えばベルギーとオランダの飛び地バールレ=ヘルトフの非常に複雑な境界線を考えると、この定理は、この境界線を必要なだけ正確に近似できる2層ニューラルネットワークが存在することを保証します。」(0:00:24) この定理は、十分な数のニューロンを持つ「幅の広い」2層ネットワークが、いかなる連続関数でも表現できることを示唆しています。
  • 幾何学的解釈: 2層ネットワークは、入力空間(この場合は地図)に「折り目」を作成することで機能します。各ニューロンは「単一の折り目に沿って地図のコピーを折りたたむ」ことができ(0:00:46)、これらが組み合わされてより複雑な表面が形成されます。最終的な出力ニューロンの表面の高さは、モデルの特定の地域がどちらかの国に属するという「確信度」に対応し、これらの表面の交点が「決定境界」を形成します(0:01:59)。
  • 実践上の課題と限界:
    • 広範なネットワークの非効率性: ソースは、100,000個のニューロンを持つ非常に「広い」ネットワークでも、バールレ=ヘルトフの複雑な境界を完全に学習できないことを示しています(0:03:54)。これは、ユニバーサル近似定理が「広いニューラルネットワークはいかなる連続関数も表現できる能力がある」ことを意味するが、「実践において実際にその解決策を見つけることができる」とは限らないことを強調しています(0:14:33)。
    • 勾配降下の制約: モデルの学習には、バックプロパゲーションと勾配降下法が用いられますが、これらのアルゴリズムは「最適な、あるいは良い解決策を見つけることを保証しない」と述べられています(0:15:10)。特定のランダムな初期化では、勾配がゼロになる(ReLU活性化関数のゼロ化された部分を通じて)ことで、モデルが最適ではない線形決定境界に「行き詰まる」ことがあります(0:18:06)。これは、特に浅いネットワークでは「高次元の損失ランドスケープで勾配降下法が局所最適解に陥る可能性が非常に低い」という一般的な認識にもかかわらず、発生し得ます(0:19:00)。
    • 必要なニューロン数の不明確さ: 定理は「所与の問題を解決するために実際に必要なニューロンの数を教えてくれない」ため(0:19:00)、100,000個のニューロンでも不十分である可能性があります(0:19:22)。

2. 深層ネットワークの優位性

  • 驚異的な効率性: ソースの核心的な発見は、ニューロンを複数層に配置する「深い」ネットワークの優位性です。「わずか130個のニューロンからなる5層ネットワークは、100,000個のニューロンからなるモデルよりも正確な境界線を学習することができ、地図をより効果的に分割することができます。」(0:04:24)
  • 活性化関数の重要性: 層を追加するだけでは効果がなく、各層の間に活性化関数を導入する必要があります。特に‌‌ReLU(Rectified Linear Unit)‌‌が用いられます。「入力値が0未満の場合、ReLUは0を返します。そして、入力値が0以上の場合、ReLUはその入力値をそのまま通過させます。」(0:11:03) ReLU関数を適用することで、各ニューロンは単なる平面ではなく「曲がった平面」を出力し(0:11:42)、これが非線形変換を可能にします。
  • 幾何学的な「折りたたみ」の連鎖: 深層ネットワークでは、各層が前の層によって生成された複雑な表面をさらに折りたたみ、スケーリングし、結合します。第1層では「直線的な折り目」が作成されますが、第2層では「もはや単純な平面ではない」表面が折りたたまれ、これにより「3つの異なる新しい折り目」が作成されます(0:21:31)。これらの折り目は単純な直線ではなく、「第1層から得られる平面の結合点で実際に曲がる」という複雑な幾何学的形状を持ちます(0:21:56)。
  • 領域の指数関数的増加: 「ReLUネットワークが地図を分割できる最大領域数は、ネットワークの層数に応じて指数関数的に増加する」ことが示されています(0:24:28)。例えば、各層に2個のニューロンを持つ4層ネットワーク(入力層と出力層を除く)は、理論上64の領域を生成できます。一方、同じ64個のニューロンを2層ネットワークの第1層に配置した場合、最大2,081の領域しか生成できません。しかし、同じニューロン数を4層に再配置すると、「理論上の最大値は7000万以上の領域に達します。」(0:26:18) この「成長率の差は説得力があり、深層学習が効果的である理由としてしばしば挙げられます。」(0:26:48) ただし、これらは理論上の上限であり、「実際には、層を追加しても深層ネットワークによって作成される領域の指数関数的な増加は通常見られません。」(0:26:48)
  • 勾配降下による複雑な学習: 深層モデルの学習は、特にバールレ=ヘルトフのような複雑な境界線において、より多くのトレーニングステップを必要としますが、「勾配降下が私たちの町の詳細な構造を捉えるために、これらの追加の小さな多角形をどのように作成するかを理解するのは非常に興味深いです。」(0:28:26) 最終的に、「わずか4層で各層に32個のニューロンを持つモデルが、このレベルの複雑さを学習できる」ことは注目に値し(0:30:07)、最終的な決定境界は「町のすべての領域を印象的に捉えています。」(0:30:11)

3. ニューラルネットワーク研究の進化と教育への貢献

  • 10年間の進歩: ソースの作成者は、10年前に最初のニューラルネットワーク関連の動画を公開して以来、この分野がどのように進化してきたかを振り返っています。「コアとなるアプローチのほとんどは変わっていないものの、これらのコアアイデアは信じられないほど複雑な問題を解決するためにスケールアップされています。」(0:30:40) 特に、損失ランドスケープの高次元性、バックプロパゲーションのメカニズム、そして本動画で示された「深層モデルがどのように再帰的に入力空間を折りたたみ、スケールし、結合し、驚くほど少ないニューロン数で信じられないほど複雑なパターンを学習できるか」が強調されています(0:31:38)。
  • Welch Labsの目的: 作成者は、自身のプロジェクトであるWelch Labsを通じて、数学と科学の教育をより良くしたいという個人的な動機を共有しています(0:32:24)。彼は、幼少期の学校での学習経験が好ましくなかったこと、そして自身の努力を通じて再び数学と科学への愛を見出した経験に言及しています。Welch Labsを継続するためには、「実現可能なビジネスを構築する必要がある」と認識しており(0:32:46)、スポンサーシップやPatreonからの支援がその目標達成に不可欠であることを述べています(0:33:09)。

結論

ユニバーサル近似定理は、理論的には2層ニューラルネットワークが任意の連続関数を近似できることを保証しますが、実践的には、特に複雑な問題において、その解決策を効率的に見つけることは困難です。

これは、勾配降下法が局所的な最適解に陥る可能性や、必要なニューロン数が指数関数的に膨大になる可能性によるものです。これに対し、深層ニューラルネットワークは、ReLUのような活性化関数を通じて非線形な「折りたたみ」操作を多層にわたって連鎖させることで、入力空間をはるかに複雑な方法で分割し、より少ないニューロン数で極めて精度の高い決定境界を学習する能力を持ちます。

この「深さ」による能力の向上は、現在のディープラーニングの成功の重要な要因であり、理論的な領域の指数関数的増加という概念によって裏打ちされています。

普遍的近似定理

AI

ディープラーニングが異常にうまく機能する理由という文脈において、提示されたソースは普遍的近似定理について以下の点を述べています。

普遍的近似定理の定義とその保証

  • 普遍的近似定理は、‌‌ジョージ・シバンコ‌‌によって1989年に証明されました。
  • この定理は、ベルギーとオランダの複雑な国境線のような、ある複雑な関数(複雑な境界線)があった場合、‌‌2層ニューラルネットワーク‌‌が存在し、この境界線を望むだけ正確に近似できることを保証します。
  • 第1層にニューロンを追加し続ければ、最終的に完全な境界線を表現できるアーキテクチャにたどり着くことが保証されています。

理論と実践のギャップ

  • 定理は「存在」を保証しますが、‌‌「実践的にその解決策を見つけられる」とは限りません‌‌。
  • 実際に、第1層に‌‌100,000個ものニューロンを持つモデル‌‌でも、都市の境界線を完全に一致させるように訓練することはできませんでした。この結果は、普遍的近似定理が実際に機能していないように感じさせます。
  • 普遍的近似定理は、「ニューラルネットワークは何でも学習できる」と誤解されることがありますが、実際には「‌‌十分に広いニューラルネットワークは任意の連続関数を表現できる‌‌」と述べています。ここでの「連続性」は、境界線を見つけるために交差する最終的な表面の連続性を指します。
  • さらに、この定理は‌‌特定のタスクを解決するために実際に必要なニューロンの数を教えてくれません‌‌。
  • 現代のニューラルネットワークが学習に用いる‌‌バックプロパゲーションと勾配降下法は、最適な、あるいは良い解決策を見つけることを保証しません‌‌。勾配降下法は、ReLU活性化関数のゼロ化された部分を通る勾配がゼロになるため、特定の初期設定から回復できず、最適ではない線形決定境界にとどまってしまうことがあります。非常に広いネットワークの場合でも、勾配降下法では到達できない良い解決策が存在する可能性があります。

ディープネットワークの利点と効率性

  • 第1層に100,000個のニューロンを持つモデルと比較して、わずか130個のニューロンを持つ‌‌5層ネットワークは、より精密な境界線を学習し、マップをより効果的に分割できました‌‌。
  • ニューロンを多層に再配置することが、モデルをはるかに強力にする理由についての問いが提起されています。
  • ‌浅いネットワークで必要なニューロンの数は、深いネットワークで必要なニューロンの数よりも指数関数的に大きくなる‌‌ことが、特定の種類の関数で示されています。これは、100,000個のニューロンでも十分ではない可能性を示唆しています。
  • ニューロンを追加の層に重ねて「‌‌深くする‌‌」ことで、‌‌驚くべき効率向上‌‌を達成できます。
  • 多層ネットワークは、折りたたみ、スケーリング、結合の操作を繰り返すことで、これらの操作を複合させ、‌‌より複雑なパターンを生成‌‌することを可能にします。
  • ReLUネットワークがマップを分割できる‌‌最大領域の数は、ネットワークの層数に対して指数関数的に増加する‌‌ことが示されています。
    • 2層ネットワークでは、最大領域数はニューロン数の多項式関数として増加します。
    • 対照的に、深いネットワークでは、層数に応じて指数関数的に増加します。
    • 例えば、64個のニューロンを1つの層に配置した2層ネットワークでは最大2,081個の領域が可能ですが、同じニューロンを4層に再配置すると、理論上7,000万以上の領域が可能になります。
  • この成長率の差は非常に説得力があり、‌‌ディープラーニングの有効性の理由‌‌としてしばしば指摘されます。
  • ただし、これらの数値は理論上の上限であり、実際には層を追加しても、深いネットワークによって作成される領域の指数関数的な成長は通常見られません。
  • それでも、わずか4層で各層に32個のニューロンを持つモデルが、町の境界線のあらゆる領域を捉えるほどの‌‌驚くべき複雑さを学習できる‌‌ことは注目に値します。
  • 結論として、深いモデルが入力空間を再帰的に折りたたみ、スケーリングし、結合することで、‌‌非常に少ないニューロンで信じられないほど複雑なパターンを学習できる‌‌ことが示されています。

ニューラルネットワークの幾何学的解釈

AI

ディープラーニングが異常にうまく機能する理由という大きな文脈において、提示されたソースはニューラルネットワークの幾何学的解釈について詳しく説明しています。特に、ニューロンが入力空間をどのように変換し、それが最終的な決定境界にどのように影響するかという点に焦点を当てています。

1. 浅い(2層)ニューラルネットワークの幾何学的解釈

  • ‌基本的な構成要素としての「平面」と「折り畳み」‌‌:

    • 現代のほとんどのニューラルネットワークは、‌‌整流線形活性化関数 (ReLU)‌‌ の一種を使用しています。
    • ネットワークの第1層の各ニューロンは、学習された重みによって制御される単一の折り目線に沿って、マップのコピーを‌‌折り畳みます‌‌。
    • 数学的には、各ニューロンは入力座標を受け取り、それぞれの座標を学習された重みで乗算し、バイアスを加えることで、‌‌平面‌‌を生成します。これらの重みは平面の傾きを、バイアスは平面の上下へのシフトを制御します。
    • ReLU活性化関数を適用すると、高さが0より小さい平面の領域は0の高さに‌‌折り畳まれ‌‌、これにより平面ではなく‌‌曲がった平面‌‌が出力されます。
  • ‌第2層での結合と決定境界の形成‌‌:

    • 第2層のニューロンは、これらの曲がった平面を受け取り、その高さを別の学習された重みで乗算し、幾何学的に曲がった部分をさらに上下に曲げたり、重み値が負の場合は折り畳まれた領域を反転させたりします。
    • これらの曲がった平面は、ニューロンによって合計され、‌‌表面‌‌を形成します。
    • 第1層からの折り目線はマップをいくつかの‌‌領域‌‌に分割し、それぞれの領域が第2層の表面で異なる平面となります。
    • これらの表面の高さは、モデルが特定の国(例:ベルギーやオランダ)にあるという確信度に対応します。
    • 2つの表面の交差は、モデルが両方の国に等しく確信を持っている場所を示し、これがモデルの学習された‌‌決定境界‌‌となり、基本的な国境を形成します。
  • ‌ニューロン数の増加による影響‌‌:

    • 普遍的近似定理は、第1層にニューロンを追加し続けると、最終的に完全な国境を表現できるアーキテクチャに到達することを保証します。
    • より多くのニューロン(例:8個、16個、…、100,000個)を追加すると、より多くの折り目を生成でき、マップをより多くの領域に分割し、より複雑な表面を形成し、より詳細な決定境界を生成します。
    • しかし、100,000個のニューロンを持つモデルでさえ、実際には国境の一部を学習しきれていない例が示されており、普遍的近似定理が実践的に機能していないように感じられると述べられています。

2. 深い(多層)ニューラルネットワークの幾何学的解釈

  • ‌「深くする」ことによる効率性と複雑性‌‌:

    • ソースは、‌‌ニューロンを追加の層に重ねて「深くする」‌‌ことによって、驚くべき効率向上を達成できることを強調しています。
    • 例えば、合計130個のニューロンを持つ5層ネットワークが、100,000個のニューロンを持つ浅いモデルよりも‌‌より正確な境界線を学習し、マップをより効果的に分割できた‌‌ことが示されています。
    • これは、浅いネットワークで必要なニューロンの数が、深いネットワークで必要なニューロンの数よりも‌‌指数関数的に大きくなる‌‌ことが、特定の種類の関数で示されているためです。
  • ‌層の積み重ねによる幾何学的変換の複合‌‌:

    • 浅いモデルと深いモデルの両方のニューロンは、同じ‌‌折り畳み、スケーリング、結合‌‌の操作を行います。
    • しかし、これらの操作が多層で複合されると、はるかに強力になります。
    • もしReLU活性化関数を使用しない場合、層を重ねても代数的に単一の層に‌‌崩壊‌‌し、実際には単一の傾いた平面しか適合できないことが示されています。これは、複雑なパターンを学習するためにReLUのような非線形活性化関数がいかに重要であるかを強調しています。
    • 深いネットワークでは、第1層が入力平面を折り畳んだ後、第2層のReLU活性化関数は、もはや単純な平面ではない表面に適用されます。これにより、複数の新しい折り目線が作成され、これらの折り目は異なる角度で、前の層の平面の接合部で曲がるという、‌‌はるかに複雑な幾何学‌‌が生成されます。
    • これにより、単一のニューロンがかなり複雑な幾何学を持つ‌‌複数の異なる折り目‌‌を作成できるようになります。
    • この再帰的な折り畳み、スケーリング、結合の操作を繰り返すことで、これらの操作は‌‌複合‌‌し、ニューロンがより複雑なパターンを生成できるようになります。
  • ‌領域数の指数関数的増加‌‌:

    • ReLUネットワークがマップを分割できる‌‌最大領域の数は、ネットワークの層数に対して指数関数的に増加する‌‌ことが示されています。
      • 浅い(2層)ネットワークでは、最大領域数はニューロン数の‌‌多項式関数‌‌として増加します。
      • 対照的に、深いネットワークでは、層数に応じて‌‌指数関数的に増加‌‌します。
    • 例えば、64個のニューロンを1つの層に配置した2層ネットワークでは最大2,081個の領域が可能ですが、同じニューロンを4層に再配置すると、理論上7,000万以上の領域が可能になります。
    • この成長率の差は非常に説得力があり、‌‌ディープラーニングの有効性の理由‌‌としてしばしば指摘されます。
    • ただし、これらの数値は理論上の上限であり、実際には層を追加しても、深いネットワークによって作成される領域の指数関数的な成長は通常見られないと注意されています。
    • それでも、わずか4層で各層に32個のニューロンを持つモデルが、町の境界線のあらゆる領域を捉えるほどの‌‌驚くべき複雑さを学習できる‌‌ことは注目に値します。
  • ‌勾配降下法の限界‌‌:

    • 普遍的近似定理は解決策の‌‌存在‌‌を保証しますが、‌‌実践的にその解決策を見つけられるとは限りません‌‌。
    • 現代のニューラルネットワークが学習に用いるバックプロパゲーションと勾配降下法は、最適な、あるいは良い解決策を見つけることを保証しません。
    • 勾配降下法は、ReLU活性化関数のゼロ化された部分を通る勾配がゼロになるため、特定の初期設定から回復できず、最適ではない線形決定境界にとどまってしまうことがあります。非常に広いネットワークの場合でも、勾配降下法では到達できない良い解決策が存在する可能性があります。

結論として、深いモデルは入力空間を‌‌再帰的に折り畳み、スケーリングし、結合する‌‌ことによって、‌‌非常に少ないニューロンで信じられないほど複雑なパターンを学習できる‌‌ことが、幾何学的な観点から明確に示されています。これにより、ディープラーニングは、従来の浅いモデルでは効率的に処理できなかったような複雑な問題を解決する上で、異常なほどの能力を発揮するのです。

浅いネットワークと深いネットワークの対比

AI

ディープラーニングが異常にうまく機能する理由というより大きな文脈において、提示されたソースは‌‌ワイドネットワーク(浅いネットワーク)‌‌と‌‌ディープネットワーク(深いネットワーク)‌‌の間の重要な違いと、それがニューラルネットワークの幾何学的解釈にどのように関連するかを詳細に議論しています。

ワイドネットワーク(浅い2層ニューラルネットワーク)の幾何学的解釈と限界

  • ‌構成と決定境界‌‌:

    • ユニバーサル近似定理は、‌‌2層ニューラルネットワーク‌‌が、十分な数のニューロンを持つ場合、ベルギーとオランダの複雑な国境のような任意の連続関数を望むだけ正確に近似できることを保証します。
    • 幾何学的には、ネットワークの‌‌第1層の各ニューロンは、学習された重みによって制御される単一の折り目線に沿ってマップを「折り畳み」ます‌‌。ReLU活性化関数が適用されることで、高さが0より小さい領域は0に「折り畳まれ」て、「曲がった平面」が出力されます。
    • 第2層のニューロンは、これらの曲がった平面を受け取り、それらの高さを別の学習された重みで乗算し、結合することで「表面」を形成します。
    • これらの表面の交差が、モデルの学習された「決定境界」となり、基本的な国境を形成します。
    • 第1層の折り目線はマップを複数の領域に分割し、それぞれの領域が第2層の表面で異なる平面となります。
  • ‌ニューロン数の増加と課題‌‌:

    • ソースは、第1層にニューロンを追加し続けることで、より多くの折り目を生成し、マップをより多くの領域に分割し、より複雑な表面と詳細な決定境界を生成できることを示しています。
    • しかし、実際には、‌‌100,000個ものニューロンを持つモデルでさえ、ベルギーとオランダの国境の一部を完全に学習しきれていない‌‌例が示されています。これは、ユニバーサル近似定理が「うまく機能していないように感じる」状況を示唆しています。
    • ユニバーサル近似定理は解決策の‌‌存在‌‌を保証するものの、‌‌実践的にその解決策を見つけられることを保証するものではない‌‌、という点が強調されています。また、特定の解決策を見つけるために実際にどれだけのニューロンが必要かについては教えてくれません。
    • 勾配降下法は、最適な、あるいは良い解決策を見つけることを保証せず、特定の初期設定から回復できない場合があり、最適ではない線形決定境界にとどまってしまうことがあります。非常に広いネットワークの場合でも、勾配降下法では到達できない良い解決策が存在する可能性があります。
  • ‌領域数の増加‌‌:

    • 2層ネットワークでは、モデルがマップを分割できる‌‌最大領域の数は、ニューロン数の多項式関数として増加します‌‌。例えば、64個のニューロンを持つ2層ネットワークでは、最大2,081個の領域を作成できます。

ディープネットワーク(多層ニューラルネットワーク)の幾何学的解釈と優位性

  • ‌驚異的な効率向上‌‌:

    • ソースは、ニューロンを追加の層に‌‌「深くする」‌‌ことによって、驚くべき効率向上を達成できることを強調しています。
    • 例えば、合計130個のニューロンを持つ5層ネットワークが、‌‌100,000個のニューロンを持つ浅いモデルよりも、より正確な境界線を学習し、マップをより効果的に分割できた‌‌ことが示されています。
    • これは、特定の種類の関数では、浅いネットワークで必要なニューロンの数が、深いネットワークで必要なニューロンの数よりも‌‌指数関数的に多くなる‌‌ことが示されているためです。
  • ‌幾何学的変換の複合‌‌:

    • 深いモデルのニューロンは、浅いモデルと同じ「折り畳み、スケーリング、結合」の操作を行いますが、これらの操作が‌‌多層で複合されると、はるかに強力になります‌‌。
    • ReLUのような非線形活性化関数がなければ、層を重ねても単一の層に「崩壊」してしまい、単一の傾いた平面しか適合できません。
    • 深いネットワークでは、第1層が入力平面を折り畳んだ後、第2層のReLU活性化関数は、もはや単純な平面ではない表面に適用されます。これにより、複数の新しい折り目線が作成され、これらの折り目は異なる角度で、前の層の平面の接合部で曲がるという、‌‌はるかに複雑な幾何学‌‌が生成されます。
    • これにより、単一のニューロンがかなり複雑な幾何学を持つ‌‌複数の異なる折り目‌‌を作成できるようになります。この再帰的な折り畳み、スケーリング、結合の操作を繰り返すことで、これらの操作が‌‌複合‌‌し、ニューロンがより複雑なパターンを生成できるようになります。
  • ‌領域数の指数関数的増加‌‌:

    • ReLUネットワークがマップを分割できる‌‌最大領域の数は、ネットワークの層数に対して指数関数的に増加する‌‌ことが示されています。
    • 例えば、64個のニューロンを4層に再配置すると、理論上7,000万以上の領域が可能になります。
    • この成長率の差は非常に説得力があり、‌‌ディープラーニングの有効性の理由‌‌としてしばしば指摘されます。
    • ただし、これらの数値は理論上の上限であり、実際には層を追加しても、深いネットワークによって作成される領域の指数関数的な成長は通常見られないと注意されています。それでも、わずか4層で各層に32個のニューロンを持つモデルが、町の境界線のあらゆる領域を捉えるほどの‌‌驚くべき複雑さを学習できる‌‌ことは注目に値します。

ワイドネットワークとディープネットワークの比較

特徴ワイドネットワーク(浅い2層)ディープネットワーク(多層)
‌幾何学的変換‌各ニューロンが入力空間に単一の折り目(線形な折り目線)を作成する。層を重ねることで、幾何学的変換が複合し、複雑な折り目や非線形な分割を生成する。
‌効率(ニューロン数)‌複雑なパターンを学習するために指数関数的に多くのニューロンが必要になる可能性が高い。‌少ないニューロンで信じられないほど複雑なパターンを学習できる‌‌。
‌マップの分割能力(領域数)‌ニューロン数の‌‌多項式関数‌‌として最大領域数が増加する。層数に対して‌‌指数関数的に‌‌最大領域数が増加する。
‌実践的な学習能力‌ユニバーサル近似定理は存在を保証するが、勾配降下法が最適な解決策を見つけられない場合がある。少ないニューロンで非常に複雑な境界線を学習し、マップを効果的に分割できる。
‌複雑性の生成‌「線を重ねただけ」のような印象の幾何学パターン。全く異なる複雑な「タイリング」(分割)を生成できる。

結論として、ディープラーニングが異常にうまく機能する理由は、深いモデルが‌‌入力空間を再帰的に折り畳み、スケーリングし、結合する‌‌ことで、‌‌非常に少ないニューロンで信じられないほど複雑なパターンを学習できる‌‌という幾何学的な能力にあります。これにより、従来の浅いモデルでは効率的に処理できなかったような複雑な問題を、はるかに効率的に解決できるようになるのです。

学習プロセスと課題

AI

ディープラーニングが異常にうまく機能する理由というより大きな文脈において、提示されたソースは、ニューラルネットワークの‌‌学習プロセス‌‌とそれに伴う‌‌課題‌‌について詳細に議論しています。特に、普遍近似定理が保証する「存在」と、実際の学習アルゴリズムである勾配降下法がその「解決策を見つける能力」との間のギャップが強調されています。

学習プロセス

ニューラルネットワークの学習プロセスは、主に‌‌バックプロパゲーションと勾配降下法‌‌に基づいて行われます。

  • ‌初期化と予測‌‌:
    • 学習前、ネットワークは‌‌ランダムに初期化‌‌されます。これにより、第1層の折り目線はマップ上のランダムな位置に配置され、トレーニング前の決定境界も初期状態では適切ではありません。
    • モデルは入力データを受け取り、その現在のパラメーターに基づいて予測を行います。例えば、ベルギーの地点が与えられた場合、初期のランダムなモデルではその地点を誤ってオランダと分類する可能性があります。
  • ‌誤差の測定‌‌:
    • モデルの予測と実際の正解との間の誤差は、‌‌クロスエントロピー損失‌‌などの損失関数を用いて測定されます。この損失値は、モデルがどれだけ間違っているかを示します。
  • ‌勾配の計算と更新‌‌:
    • 測定された損失は‌‌バックプロパゲーションアルゴリズム‌‌を通じて実行され、各モデルパラメーター(重みとバイアス)に対する‌‌勾配‌‌が計算されます。
    • 勾配は、損失を減少させるために各パラメーターをどのように調整すべきかを示します。例えば、ある重みに対する勾配が大きく負である場合、損失を減らすためにはその重みを増やすべきだと示唆されます。
    • これらの勾配に従って、モデルのパラメーターは‌‌小さな反復的な更新‌‌を受けます。これにより、折り目線の位置や、これらの曲がった平面がどのように結合されるかが調整されます。
    • この勾配降下プロセスをステップバイステップで繰り返すことで、モデルは徐々に損失を減らし、より正確な決定境界を学習します。
  • ‌学習の停止‌‌:
    • 通常、学習プロセスは、モデルのパフォーマンスが向上しなくなった時点で停止されます。

学習の課題と限界

ソースは、特にワイド(浅い)ネットワークにおいて、学習プロセスが直面するいくつかの重要な課題を指摘しています。

  • ‌普遍近似定理の「落とし穴」‌‌:
    • ‌普遍近似定理‌‌は、十分な数のニューロンを持つ2層ニューラルネットワークが、任意の連続関数を望むだけ正確に近似できることを保証します。
    • しかし、この定理は‌‌解決策が「存在する」ことを保証するものの、実践的にその解決策を「見つけられる」ことを保証しません‌‌。
    • また、定理は‌‌特定のタスクを解決するために実際にどれだけのニューロンが必要か‌‌を教えてくれません。
  • ‌勾配降下法の限界‌‌:
    • 勾配降下法は、‌‌最適な、あるいは良い解決策を見つけることを保証しません‌‌。
    • モデルの初期化が悪い場合、勾配降下法は‌‌望ましくない構成から回復できない‌‌ことがあります。例えば、決定境界が平面から押し出されてしまい、ReLUのゼロ化された部分に入ってしまうと、その部分の勾配もゼロになるため、モデルは実質的に単一の平面でしか機能せず、最適ではない線形決定境界にとどまってしまいます。これは、‌‌「デッドニューロン」‌‌として知られる現象の一種で、特定のニューロンの出力が常に0になることで、そのニューロンが学習に貢献できなくなる状態を指します。
    • 非常にワイドな10万ニューロンのネットワークの場合でも、良い解決策が存在するにもかかわらず、勾配降下法では到達できない可能性があります。
    • 大規模モデルでは勾配降下法が局所最適解に陥る可能性は低いとされていますが、それでも解決策を見つけることの難しさは残ります。
  • ‌ニューロン数の多さの非効率性‌‌:
    • ユニバーサル近似定理が示すようにニューロン数を増やし続けることで、確かに真の境界線に近づくことはできますが、‌‌10万個ものニューロンを持つモデルでさえ、ベルギーとオランダの国境の一部を完全に学習しきれていない‌‌例が示されています。
    • 特定の種類の関数では、浅いネットワークで必要なニューロンの数が、深いネットワークで必要なニューロンの数よりも‌‌指数関数的に多くなる‌‌ことが示されています。これは、ただニューロンを増やして「ワイドにする」だけでは効率が悪いことを意味します。
    • 理論上、浅いネットワークが生成できる最大領域の数はニューロン数の多項式関数として増加するのに対し、深いネットワークは層数に対して‌‌指数関数的に‌‌増加します。この効率の差が、ディープラーニングが「異常にうまく機能する」理由の重要な側面です。

まとめると、ディープラーニングの学習プロセスは、バックプロパゲーションと勾配降下法による反復的なパラメーター調整によって行われますが、その成功は普遍近似定理が保証する「存在」と、勾配降下法が実際に「見つける」能力との間の複雑な相互作用に依存します。‌‌ディープネットワークは、はるかに少ないニューロンで驚くほど複雑なパターンを学習できる‌‌ことが示されており、これは、多層構造が幾何学的変換を複合させ、学習プロセスがより効率的かつ効果的に機能するような入力空間の分割を可能にするためであると考えられます。

AI

情報源

Why Deep Learning Works Unreasonably Well

動画(34:08)

https://www.youtube.com/watch?v=qx7hirqgfuU

動画概要欄

63,100 views Aug 10, 2025

Take your personal data back with Incogni! Use code WELCHLABS and get 60% off an annual plan: http://incogni.com/welchlabs

New Patreon Rewards 33:31- own a piece of Welch Labs history!

展開

In 1989, George Sibanko proved what's now known as the Universal Approximation Theorem. If we take some complex function, for example this really complicated border in the town of Barley-Hertog, these parts of the map are in Belgium and these parts are in the Netherlands, the Universal Approximation Theorem guarantees that there exists a two-layer neural network that can fit this border as precisely as we want. (0:00:24)

A nice way to get a feel for this result is to see what a two-layer network like this does geometrically. Most modern neural networks use some version of rectified linear activation functions. Visually this means that each neuron in the first layer of our network folds up a copy of our map along a single fold line, where the location of the fold line is controlled by the neuron's learned weights. (0:00:46)

From here, our first neuron in our second layer takes in these bent planes, and multiplies their heights by another learned weight value, which geometrically further bends up or down the folded parts of our planes, and flips over our folded region when that neuron's weight value is negative. These three bent planes are then added together by our neuron, resulting in a surface like this. Our three fold lines from our first layer now divide up our map into these five regions, that each become different planes in our second layer's surface. (0:01:17)

This surface shows the output of our first neuron in our second layer. The second neuron in our second layer flips, scales, and combines our first planes using different learned parameters, resulting in this surface, that again uses the same five regions of our map, but at different heights. The height of the surface formed by our first neuron corresponds to the model's confidence in a certain part of the map being in the Netherlands. And the height of the second neuron's surface corresponds to the model's confidence in Belgium. Coloring our Netherlands surface blue, and our Belgium surface yellow, and bringing these surfaces together onto the same axis, the intersection of our surfaces shows us where our model is equally confident in both countries. (0:01:59)

This is the model's learned decision boundary, which gives us a basic border, separating the core Belgium region from the surrounding Netherlands region. Now the universal approximation theorem tells us that if we just keep adding neurons to our first layer, eventually we'll land on an architecture capable of representing our full border. Training a network with 8 neurons in its first layer, we get this set of 8 folds, leading to this surface for our first output neuron, and this surface for our second output neuron. (0:02:29)

Bringing these new surfaces onto the same axis, we see these new more complex intersection lines, leading to this more detailed final border, that begins to break our map into separate regions. Here's the surfaces and border for a larger model with 16 neurons. Here's a 32 neuron model, here's 64, and here's 128. It starts to become difficult to see how our surfaces are intersecting exactly with this many fold lines. (0:02:57)

Let's flatten out our surfaces, to make it easier to see how the model uses all its different fold lines to fit our border. (0:03:04)


Doubling our neuron count again to 256. Here's how our neurons divide up our map, and here's the final decision boundary. Here's 512 neurons, and here's 1024. We're getting closer to our true border, but we're still missing a number of parts of the town, and we've reached a point where I can't actually render any more polygons, but we can still render our decision boundary. (0:03:26)

Here's the border we get with a 10,000 neuron model. And finally here's a model with 100,000 neurons. We're getting even closer at this point, but even with 100,000 neurons, there's a couple parts of the border that our model hasn't learned. It feels like the universal approximation theorem isn't really working. What are we missing here? But before we get into the details of what's going wrong, let me show you one more thing. (0:03:54)

Let's take just 128 neurons, but instead of arranging them in a single wide layer, let's arrange them in 4 separate layers of 32 each, like this, where the output of each layer is passed into the next. After training this model, these are the resulting learned regions and decision boundary. Our 5-layer network, with just 130 total neurons, is able to learn a more precise border than our 100,000 neuron model, and it's able to divide up our map more effectively. (0:04:24)

How is it that rearranging our neurons into multiple layers makes our model so much more powerful? The neurons in both our deeper and shallow models do the same folding, scaling, and combining operations. Why are these operations so much more effective when composed in multiple layers? And how does the geometry of our map change as it moves through these stacked operations? This video is part of a series sponsored by Incogni. These videos have really pushed my animation abilities, requiring a bunch of deeply focused hours, which Incogni has really helped me with by significantly reducing the number of spam texts and calls that I receive. (0:05:05)

Incogni also helps protect my privacy. In the United States we have these people search sites, where for a small fee anyone can look up information about you, like your address, your email, phone number, education, employment history, social media accounts, and so on. This gives you an idea of all the information about you that data brokers are able to gather and sell. Last year I signed up for one of these people search sites, to see what information I could find on myself. (0:05:30)

After being an Incogni customer for a few months, I impressively wasn't able to find any information on myself, but I was able to find a ton of information on my wife. Since then I've upgraded to Incogni's friends and family plan and added my wife to the plan. I checked the same people search site again this week, and was happy to see that all of her information had been removed. (0:05:51)

Incogni has just released a new feature, that makes their service even more effective, called custom data removals. (0:05:58)


If you type your name and address into Google, you may be surprised to find where exactly your personal information pops up. With custom removals, you can submit specific URLs directly to the Incogni team, who will work to remove your information from eligible sites. You can get a great deal on Incogni, 60% off an annual plan, by visiting incogni.com forward slash welchlabs, and using code welchlabs at checkout. (0:06:21)

It's been a while since I've made a multi-part series like this. Huge thanks to Incogni for helping make this series possible, and helping me get more quality focus time as I work on it. Last time, in part 2 of this series, we dug into the mathematics of how modern models are trained using backpropagation and gradient descent. We saw how given the inputs of latitude and longitude, a single layer model can effectively learn to position planes over different European cities, learning to separate Paris, Berlin, Madrid, and Barcelona. The key piece of functionality here is that our model learns to position the Madrid plane above all the other planes above Madrid, the Barcelona plane above all the other planes above Barcelona, and so on. (0:07:04)

And the height of our planes corresponds to our network's final confidence in a specific city. We left off considering the most complex geographic border in the world, between Belgium and the Netherlands, in the municipality of Barley-Hertog. Given a single plane for each country, there's no way to position our planes, so our Belgium plane is on top of our Netherlands plane above only the Belgium portions of our map. (0:07:29)

Another way to think about this is that our two tilted planes intersect at a line on our map, where everything on one side of the line will be classified as part of Belgium, and everything on the other side will be classified as part of the Netherlands. And there's no way this linear decision boundary can correctly divide up our city. Our networks from last time looked like this, with a single layer of neurons between our inputs and softmax function. (0:07:53)

As we saw last time, the softmax function bends our planes to output nice final probability values. But importantly, it doesn't change the location of the decision boundaries at the intersections of our planes. For this reason, we won't concern ourselves too much with softmax in this video. The networks we saw at the beginning of this video add one more layer of neurons, and our models are able to accomplish significantly more. (0:08:17)

Just like the neurons in our simple single layer model, each of the neurons in the first layer of our two layer network contains a simple linear model that geometrically looks like a plane. Mathematically, the first neuron in our first layer takes in the coordinates of our point, multiplies each coordinate by a learned number called a weight, which we're writing here using lowercase m's, and adds these results together. (0:08:41)

The weight values control the steepness of our plane in each direction. (0:08:44)


Finally, we add one more learnable parameter called a bias. This shifts our whole plane up and down. So if we pass in this Belgian point on our map, with coordinates of x1 equals 0.6 and x2 equals 0.4, we multiply our x1 value by our first weight, and our x2 value by our second weight, and add these results together. And finally, we add our bias value to compute our final result of minus 0.14. This computed value corresponds to the height of our first neuron's plane at these input coordinates. Now, if we just pass the height of our plane, minus 0.14 in this example, into our second layer of neurons, our multiple layers of neurons will actually just collapse back down into what is effectively a single layer of neurons. (0:09:31)

We can show this collapsing algebraically. There's just a bunch of terms to deal with. These first two equations correspond to the first two neurons in our first layer. Note that we're using these superscripts to keep track of where each weight comes from. Everything with a superscript of 1 comes from our model's first layer. Here's the equation for the first neuron in our second layer. (0:09:52)

If we pass the outputs of our first layer directly into our second layer, this is equivalent to plugging in our first set of equations into our second equation, like this. Distributing and collecting terms, we end up with a new constant times our input x1, plus another new constant times our input x2, plus this final constant. This equation has the same shape as our individual neuron equations, just with different constants. (0:10:18)

This result tells us that if we just hook up the outputs of one layer of plane-fitting neurons to the inputs of our next layer, we end up adding together different tilted planes, which just results in a different tilted plane. So a two-layer network connected like this is still only capable in practice of fitting two planes to our map, just as our single-layer model did. (0:10:40)

For our multi-layer neural network to be able to learn more complex patterns, we need to add one more small piece of math. We'll pass the output of our planes from our first layer into a function called an activation function that will modify their shape into something more complex for our model to work with. It turns out that we can build high-performing neural networks using a variety of activation functions. (0:11:03)

But one of the simplest and most widely used today is a function called a rectified linear unit, or ReLU. ReLU is incredibly simple. For input values less than 0, ReLU returns 0. And for input values greater than or equal to 0, ReLU simply passes its input value through. So ReLU of minus 1 is 0, and ReLU of 1 is 1. Applying our ReLU activation function to the output planes of our first layer, the regions of our plane with heights less than 0 are folded up or clipped to a height of 0. So instead of outputting planes, the first layer of our network now outputs these bent planes. (0:11:42)

This is the folding operation we saw at the beginning of the video. (0:11:46)


So to decide which country a point is in, for example this Belgium point with coordinates of 0.6, 0.4 that we saw earlier, we pass these coordinates into our first layer of neurons, and get values of minus 0.14 and minus 0.33 out, corresponding to the height of each of our planes at the input coordinates of our point. From here we apply our ReLU activation function, folding all values below 0 up to 0. The height of our point on both planes is negative, so we set both points to 0. So our input point 0.6, 0.4 has now been mapped to values of 0, 0 by our bent planes. (0:12:25)

From here our final layer of neurons multiplies these values of 0, 0 by its weights, and adds its bias terms. Shifting our combined bent planes up and down, moving our point to 0.03 on our top surface, and minus 0.89 on our bottom surface. Our second neuron's output corresponds to our model's confidence in Belgium, which is higher in this case, meaning this point will be classified as being in Belgium. And visually we see this point on our Belgium plane being above our point on our Netherlands plane. (0:12:57)

We can do a similar analysis for a point in the Netherlands, like this point at 0.3, 0.7. The key difference here is that this point does not fall in the 0 ReLU region of our second neuron, meaning that it gets pushed up on our final Netherlands bent plane, and pushed down on our final Belgium plane, resulting in a correct Netherlands classification. So our bent plane geometry is equivalent numerically to moving data through our network, but gives us a nice way to see how all of the points on our map are processed at once. (0:13:30)

As we add more neurons to our first layer, we're able to make more and more folds in our map, cutting our map into more and more regions for our output neurons to push up and down into more and more complex surfaces. Now, as we saw at the opening of the video, assuming a sufficient number of neurons in our first layer, the Universal Approximation Theorem tells us that a two-layer neural network exists that can represent the borders of our town at arbitrarily high precision. (0:13:57)

But as we saw, even at 100,000 neurons in our first layer, we were not able to successfully train a model to completely match our borders. What is going on here? The Universal Approximation Theorem is sometimes mistaken to mean that neural networks can learn anything. But what it really says is that a wide enough neural network is capable of representing any continuous function. Now, the borders of our town are actually not continuous, but the continuity that the theorem is referring to here is actually the continuity of the final surfaces that we intersect to find our border. (0:14:33)

The real issue here is that although the Universal Approximation Theorem tells us that a two-layer solution exists, it does not mean that in practice we can actually find the solution. (0:14:44)


And the theorem does not tell us how many neurons we actually need to solve a given problem. As we saw in parts 1 and 2 of this series, modern neural networks learn using backpropagation and gradient descent, which provide no guarantees of finding the best or even a good solution. Instead, these algorithms make small iterative updates to our parameters. And we typically just stop the learning process when performance stops improving. (0:15:10)

Before training, our network is randomly initialized, placing our fold lines at random locations on our map. Here's one initialization for our five-neuron, two-layer model. Here's how our folded planes are combined by the second layer of this model. And here's how these surfaces intersect to form a decision boundary before training. If we pass in the Belgian point we considered earlier into our randomly initialized model, this point ends up on this planar region in our second layer's surface. (0:15:39)

This first neuron surface ends up on top in our final output, shown here in blue, meaning that our model incorrectly classifies our point as being in the Netherlands. This error is measured using the cross-entropy loss, as we saw in part 2. And this loss is then run through our backpropagation algorithm, resulting in gradient values for each of our model's 17 parameters. Some of the largest resulting gradients are for this third neuron in our first layer. (0:16:06)

Both our DLDM31 and our DLDB3 gradients are large and negative. Currently, M31 is negative, tilting our plane down in the X1 direction. Our gradient is telling us that to decrease our loss, we should increase M31, which will reduce the slope of our plane, making it flatter. Backpropagation also returns a large negative value for DLDB3, which tells us to shift our whole plane upwards. (0:16:36)

Adjusting our parameters in this direction moves our plane, and shifts our ReLU joint line to the right. Zooming out to our full network, we can see how this update moves the center fold line in our second layer to the right. On our final surfaces, our update moves our top blue surface down, reducing the model's confidence in the incorrect answer of the netherlands, while moving our decision boundary to the right. (0:17:02)

We can now repeat this gradient descent process, and watch our model learn. Step by step, these small updates adjust both the locations of the fold lines in our first layer, and the way these bent planes are combined by our second layer, until we have a nice concave down surface on top of Belgium, that intersects a concave up netherlands surface at a nice border. (0:17:24)

Now, when I initially tried to train this model, it didn't actually work nearly this well. I had a different random initialization that looked more like this, placing our blue surface on top of our yellow surface, when we want our model to learn the exact opposite orientation, with a central yellow region for Belgium on top. As our model learns from this starting point, our backpropagation algorithm begins to reverse the orientation of these surfaces, lowering our loss values, and moving the blue surface down and the yellow surface up. (0:17:57)

But in doing so, backpropagation pushes the decision boundaries off of our planes, leaving our whole town in the zeroed out part of our bent ReLU plane. (0:18:06)


Gradient descent is not able to recover from this configuration, since the gradients through the zeroed out part of our ReLU activation function are also zero, leaving our model with effectively a single plane to work with, resulting in a suboptimal linear decision boundary. So even though we know that a nice solution exists for our 5-neuron network, given this starting point, gradient descent is not able to find it. (0:18:31)

In the case of our super-wide 100,000-neuron network, there may be analogously good solutions out there, we just can't reach them with gradient descent. Now, there is some subtlety here. As we saw back in part 1, when models become large, the chances of gradient descent actually getting stuck in a local minimum in this high-dimensional loss landscape becomes very small. Our super-wide network is probably not getting stuck in quite the same way as our small network. (0:19:00)

In addition to not telling us how to find a specific solution, the universal approximation theorem also does not tell us how many neurons we actually need to solve a given problem. And in fact, for a broad class of functions, it's been shown that the number of neurons we need in a shallow network is exponentially larger than the number of neurons needed in a deep network. (0:19:22)

So it's possible that 100,000 neurons may actually not be enough. Finally, it's difficult to prove a negative. In the course of making this video, I experimented with a bunch of different optimizer configurations for these wide models. But it wouldn't surprise me if there's a way to train a 100,000 neuron, a 10,000 neuron, or maybe even smaller two-layer model to fit the borders of our town. (0:19:44)

I'll leave a link to my code in the description if you want to experiment. And please send me your results if you make progress. I would love to see a solution. Exact number of neurons aside, as we saw earlier, we can make incredible efficiency gains by going deep instead of wide, stacking our neurons into additional layers. And that's what we'll turn our attention to next. (0:20:04)

What new geometry does stacking our layers create? And how does this geometry help our model learn the complex borders of our town? Let's begin with a simple two-layer model with two neurons each. This simple two-layer model learns these folds in our map, which are combined by our second layer into this bent-up surface and this bent-down surface. Taking the intersection of our surfaces, where our model is equally confident in both countries, we get this simple decision boundary. (0:20:33)

Now, let's add a third layer to our model with two additional neurons. So we now have three layers and six neurons total. After training, our first layer learns to fold our input planes like this, and our second layer learns to combine our bent planes like this. Now, if we only had two layers, we would just bring these surfaces together to form our final decision boundary. (0:20:56)

But we now have a whole additional layer of transformations to apply. (0:21:00)


Just as we did in our first layer, we now need to apply our ReLU activation function, where all of the values on our surface with heights less than zero are set to zero. In our first layer, this operation folds our planes along linear fold lines. But now in the second layer of our model, the surfaces we're folding are no longer simple planes. If we add a plane at z equals zero to our first neuron surface, we can see that this surface actually has three separate planes that all cross z equals zero. (0:21:31)

When we apply our ReLU activation function and fold up our surface, we create three separate new fold lines, one for each region that crosses the z equals zero plane. And interestingly, these folds are not at the same angle, but actually bend at the joints of the planes we get from our first layer. So here a single neuron is able to make three separate folds, with fairly complex geometries. (0:21:56)

Our second neuron in our second layer applies the same operations, but with different learned weights, resulting in these three new folds. Now, just as our previous two layers did, our third and final layer scales and adds our new surfaces together. After our first layer, the combination of our two ReLU folds created four regions for the next layer of our model to work with. (0:22:21)

These are easiest to see in a 2D projection like this. Stacking the new fold lines from our second layer, these new folds at various angles come together in a significantly more complex tiling of our map, with these ten separate regions. When the final layer of our network scales and adds together the outputs of our second layer, the resulting surfaces are composed of the same ten regions, just with different heights. (0:22:46)

The height of these surfaces corresponds to the model's final confidence in our two countries. Bringing these surfaces together and finding their intersection, we get this final decision boundary, which shows some nice piecewise linear curvature around the Belgian regions of our map. So the first layer of our network creates these two folds and four separate regions on our map, which are then split by our second layer into these ten regions, which are used by our final layer to create these surfaces, which intersect in a nice border. (0:23:18)

The fact that just adding two additional neurons takes our map from these four regions to these ten is remarkable to me, especially considering the complex geometry of these ten regions. If we instead arrange our six neurons in a two-layer network like this, our model learns to fold four copies of our map like this, resulting in these seven regions, these surfaces, and this final decision boundary. (0:23:43)

This decision boundary isn't necessarily worse than the one learned by our deeper model, but I'm particularly struck by how much more complex the tiling learned by our deeper model is. Qualitatively, the tiling of our map learned by our shallow network feels very much like we've just stacked four lines together, which is exactly what we've done. (0:24:03)


While the tiling learned by our deeper model feels to me like something entirely different. By repeating our folding, scaling, and combining operations, these operations are able to compound on themselves, allowing the neurons in our second layer to generate significantly more complex patterns than they would if they were instead positioned in the first layer of our model. The compounding analogy is not a coincidence. (0:24:28)

It turns out that we can show that the maximum number of regions a ReLU network like ours can divide our map into grows exponentially with the number of layers in our network. This equation gives the theoretical maximum number of regions our model can create as a function of the number of neurons in each layer, d, the number of inputs, d sub i, and the number of layers in our network, k, not including our final output layer. (0:24:53)

Plugging in d equals two neurons per layer, d sub i equals two inputs, and k equals two layers, we get 2 squared times 4 equals 16 total possible regions for our model. This is a bit above the 10 regions our model actually learned. If we add another two-neuron layer to our model, our number of regions grows to 2 to the power of 4 times 4 equals 64. And adding another layer gets us to 256 and so on. (0:25:20)

So each layer theoretically quadruples the number of regions our model can create in this configuration. This final polynomial part of the equation captures what happens in the final layer of our model. If we cut back down to a shallow two-layer model, k becomes 1, eliminating the exponential growth term. As we've seen, two-layer networks divide up the input plane by stacking separate ReLU folds. (0:25:46)

So finding the number of regions we can divide our map into with a two-layer network is equivalent to asking how many separate regions we can split a plane into with d lines. This is a well-known result in combinatorial geometry with the answer given by this polynomial. So our theory tells us that the maximum number of regions we can create with a two-layer network grows as a polynomial function of our number of neurons, while the number of regions we can create with a deeper network grows exponentially with the number of layers. (0:26:18)

Placing 64 neurons in the first layer of a two-layer network like this results in a maximum of 2,081 possible regions, while rearranging these neurons into four layers instead results in a theoretical maximum of over 70 million possible regions. The difference between these growth rates is compelling and is often pointed to as a reason for the effectiveness of deep learning. However, these numbers are theoretical upper bounds, and as a number of papers have pointed out, these bounds are very loose. (0:26:48)

In practice, we typically do not see exponential growth in the number of regions created by deep networks as we add layers. Let's scale up our own deep network and see how our number of regions scales with our network and how our fit improves. (0:27:02)


We left off with this three-layer, six-neuron model that divided our map into these ten regions, resulting in this final decision boundary. Let's first expand our model to have eight neurons in each of our first two layers. The eight folds in our first layer now break up our map into these 19 regions. And the various folds of the surfaces created by our second layer come together in these 102 regions. (0:27:28)

Our second layer patterns start to get really interesting. Here, the ReLU function in our second neuron is folding our surface along ten different unique joints. Our final layer scales and combines these outputs into these final surfaces, which intersect like this, resulting in this final decision border, capturing the two largest sections of our town nicely. Note that a couple of the neurons in our second layer don't have any colored regions. (0:27:56)

This means that the entire surface from our first layer was below z equals zero, and all inputs are set to zero by our ReLU activation function. Dead neurons like this are common, and a reminder that gradient descent gives no guarantees about efficiently using our model architecture. Let's add another eight-neuron layer to our model, resulting in four total layers. We can now really start to see the compounding effects of our repeated folding, scaling, and combining operations. (0:28:26)

The ReLU folding happening in this third neuron of our third layer creates these tiny regions around the border. It's so interesting to me that our model, guided by backpropagation, figures out how to create all these extra little polygons around our town's borders to capture their detailed structure. Now, at this scale, it becomes tough to make sense of everything that's happening in 3D space like this. (0:28:50)

Let's focus on the regions formed on our 2D map by each layer, the final 3D surfaces, and our final decision boundary. Let's watch our model learn from this perspective. Before training, here's how our model initially divides up our input space, creating this decision boundary. Before we start the training process, let's add one more panel that will track the model's loss as it learns. (0:29:12)

In less than 100 gradient descent steps, our model is able to pick out the core structure of our town and then is able to progressively tighten its borders as it learns, creating more and more regions around the fine details of the border. Finally, let's add one more layer, bringing our total number of layers to five, and increase our width one last time to 32 neurons. (0:29:38)

Our additional layer gives us one more tiling of our map. And at this scale, our 3D plot becomes a bit too chaotic to make sense of. So we'll just watch the 2D plots in this final training animation. Unlike our smaller models, this deeper model really benefits from more training steps, using the extra steps to refine the details of our town's border. The fact that just four layers with 32 neurons each can learn this level of complexity is remarkable to me. (0:30:07)

Our final decision boundary impressively captures every region of our town. (0:30:11)


It's incredible to me that a bunch of little linear models can come together to do something so complex, and that we can actually find these solutions using gradient descent. Around ten years ago, I released the very first Welch Labs video. It's called Neural Networks Demystified. Like the series you're watching now, Neural Networks Demystified was a series about how neural networks learn, focusing on backpropagation and gradient descent. (0:30:40)

Sitting down to work on this series ten years later, I honestly didn't know where to start. Although most of the core approaches in my old videos are unchanged, these core ideas have been scaled to solve unbelievably complex problems. And this shocking ability to scale has led the research community to dig deeper into what makes these models tick. We've learned a great deal in ten years, but many mysteries remain. (0:31:05)

In part one of this series, we dug into lost landscapes, and we saw how the standard mental picture of gradient descent that I presented ten years ago really doesn't hold up in the incredibly high-dimensional spaces these models operate in. In part two, we dug into the core mechanics of how models learn, dissecting backpropagation in the context of a modern large-language model. Finally, in this video, we saw how deep models are able to recursively fold, scale, and combine their input spaces, learning incredibly complex patterns with remarkably few neurons. (0:31:38)

Maybe in another ten years, I can make another series like this. We'll have to wait and see what these models can do then, and how much sense we'll be able to make of how they do it. Back in 2019, I completely quit Welch Labs. I had just tried going full-time creating videos, but I wasn't able to earn enough money to make it work. (0:32:00)

I got frustrated, and I quit. I went off and worked as a machine learning engineer, which was great, but I couldn't shake the feeling that I was really supposed to be making videos. Starting in 2022, I slowly eased back on TikTok, and was able to gradually build enough momentum to take another crack at going full-time last year. When I quit in 2019, I had some time to really think about what kept pulling me back into making videos. (0:32:24)

And I realized that deep down, it was really about education. I loved math and science as a kid, but I really disliked the way I had to learn it in school. After undergrad, I really found myself questioning if I even liked math at all. Only through my own work and study did I fall back into love with math and science years later. And now, I want to use Welch Labs to make education better. (0:32:46)

But I've realized, for me to be able to do this, I have to first build a viable business. If I can't support myself and my family, I can't spend the time I need to make this work. Last year, through sponsorships, poster and book sales, and support on Patreon, I was able to make about half of what I made as a machine learning engineer. (0:33:05)

I'm not going to lie, so far this is a much harder way to earn a living. (0:33:09)


My goal this year is to replace my full income. This will allow me to really reach escape velocity and continue full time on Welch Labs. Sponsorships, posters, and book sales are going well this year. But to hit my goal, I need to grow Patreon as well. Your monthly support on Patreon would mean a lot. As a way to say thank you, today I'm launching a new reward. (0:33:31)

Starting at the $5 per month level, I'll send you a real paper cutout used in a Welch Labs video. It comes in a nice protective sleeve with the Welch Labs logo on the front, and on the back it says the video it came from, the release date, and a sign by me. These are a lot of fun. (0:33:49)

I have them going all the way back to 2017. At the $5 per month level you'll receive a smaller cutout, and a larger cutout at the $10 or higher level. Cutouts ship after your first monthly payment goes through, and you'll find a link to the Welch Labs Patreon in the description below. Huge thank you to everyone who's supported Welch Labs over the years. (0:34:06)

Thanks for watching. (0:34:07)