0Pricing
Deep Learning Academy · レッスン

小さなネットワークを手計算で逆伝播する

紙の上で勾配を計算し、コードで確認します

「小さなネットワークを手計算で逆伝播する」はCoddyKit上の無料Deep Learning Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはDeep Learning Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Deep Learning Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Our Tiny Network

Let's hand-trace the smallest net: one input x, one weight w, no bias. The output is simply y = w times x. Tiny enough to do on paper.

y = w * x

Add a Simple Loss

We compare the output to a target t with squared error. This loss punishes being far from the target and is easy to differentiate by hand.

loss = (y - t) ** 2

Forward With Numbers

Plug in x = 2, w = 3, t = 10. Forward gives y = 6 and loss = (6 - 10) squared = 16. Now we walk backward to find dloss/dw.

Step One: Loss to Output

First link: how does loss change with y? The derivative of (y - t) squared is 2(y - t), which here is 2 times (6 - 10) = -8.

dloss_dy = 2 * (y - t)

Step Two: Output to Weight

Second link: how does y change with w? Since y = w times x, dy/dw is just x, which is 2 in our example.

dy_dw = x

Chain the Two Together

The chain rule multiplies the links: dloss/dw = dloss/dy times dy/dw = -8 times 2 = -16. That single number is our gradient.

dloss_dw = dloss_dy * dy_dw

Read the Gradient's Sign

A negative gradient means increasing w would lower the loss. So we should nudge w upward to do better next time.

Take One Update Step

With a learning rate of 0.1, the update is w = w - 0.1 times (-16) = 3 + 1.6 = 4.6. The weight moved toward a better value.

w = w - lr * dloss_dw

Confirm It Improved

Redo the forward pass with w = 4.6: y = 9.2 and loss = (9.2 - 10) squared = 0.64. Far below 16, so the step truly helped.

Check It in PyTorch

PyTorch gets the same gradient automatically. Set requires_grad on w, run forward, call backward, and read w.grad to see -16.

w = torch.tensor(3.0, requires_grad=True)
loss = (w * 2 - 10) ** 2
loss.backward()
print(w.grad)

Same Steps, Bigger Nets

A million-weight net does exactly this, just with more links chained together. The math you did by hand scales straight up.

Quick Check

Let's check your hand trace.

Recap

You traced a tiny net: forward for values, then backward multiplying local derivatives to get the gradient, then one step that lowered the loss. ✏️

よくある質問

「小さなネットワークを手計算で逆伝播する」レッスンは無料ですか?

はい。「小さなネットワークを手計算で逆伝播する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Deep Learning Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Deep Learning Academyコースには全4レッスンが含まれています。

「小さなネットワークを手計算で逆伝播する」で何を学びますか?

紙の上で勾配を計算し、コードで確認します ブラウザで直接実行するハンズオンコードでDeep Learning Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Deep Learning Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのDeep Learning Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。

「小さなネットワークを手計算で逆伝播する」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このDeep Learning Academyレッスンでコードを書いて実行できますか?

はい。すべてのDeep Learning Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. レイヤーごとにたどる連鎖律
  2. 順伝播でキャッシュし、逆伝播で再利用する
  3. 小さなネットワークを手計算で逆伝播する
  4. 勾配消失と勾配爆発
← Deep Learning Academyに戻る