パーセプトロンをゼロから実装する
数行のPythonでニューロンを実装します
「パーセプトロンをゼロから実装する」はCoddyKit上の無料Deep Learning Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはDeep Learning Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Deep Learning Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
What Is a Perceptron
A perceptron is one neuron plus a learning rule. It is the original trainable building block of neural networks, and you can code it from scratch. 🛠️
Start with Weights
First create the weights and a bias. Starting them at zero is fine for a perceptron; learning will move them where they need to be.
weights = [0.0, 0.0]
bias = 0.0Predict with a Step
The predict step computes the weighted sum, then applies the step function to return 0 or 1.
score = w[0]*x[0] + w[1]*x[1] + bias
return 1 if score >= 0 else 0Measure the Error
Compare the prediction to the true label. The error is simply target minus prediction: 0 when right, plus or minus one when wrong.
error = target - predictionThe Update Rule
The update rule nudges each weight by the error times the input. Wrong guesses push the weights toward the correct answer.
w[i] += lr * error * x[i]Update the Bias Too
The bias learns the same way, but its input is always 1. So you simply add the learning rate times the error.
bias += lr * errorThe Learning Rate
The learning rate scales how big each update is. Small values learn slowly but steadily; large ones can overshoot the answer.
lr = 0.1One Pass: an Epoch
Looping once over every training example is called an epoch. You usually repeat for several epochs until mistakes stop.
The Training Loop
Each step of training predicts, measures error, and updates the weights and bias. Repeat across the dataset to learn.
for x, target in data:
err = target - predict(x)
update(x, err)It Learns AND
Feed it the AND truth table and the perceptron converges fast. Both inputs must be 1 for it to output 1.
Convergence Guarantee
If the data is linearly separable, the perceptron is guaranteed to find a separating line. That promise is the convergence theorem.
Quick Check
Recall how a perceptron corrects itself.
Recap
A perceptron predicts with a step, measures error, and updates weights by lr times error times input. Repeat over epochs and it learns separable data. ✅
よくある質問
「パーセプトロンをゼロから実装する」レッスンは無料ですか?
はい。「パーセプトロンをゼロから実装する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Deep Learning Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Deep Learning Academyコースには全4レッスンが含まれています。
「パーセプトロンをゼロから実装する」で何を学びますか?
数行のPythonでニューロンを実装します ブラウザで直接実行するハンズオンコードでDeep Learning Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Deep Learning Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのDeep Learning Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。
「パーセプトロンをゼロから実装する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このDeep Learning Academyレッスンでコードを書いて実行できますか?
はい。すべてのDeep Learning Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 重み、バイアス、重み付き和
- ステップ関数と線形な判定
- パーセプトロンをゼロから実装する
- XOR問題:ニューロンが1つでは足りない理由