Zakodować perceptron od podstaw
Zaimplementować neuron w kilku wierszach kodu Python
Zakodować perceptron od podstaw to bezpłatna lekcja Deep Learning Academy na CoddyKit. To lekcja 3 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Deep Learning Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Deep Learning Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
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. ✅
Często zadawane pytania
Czy lekcja „Zakodować perceptron od podstaw” jest bezpłatna?
Tak — pełny tekst „Zakodować perceptron od podstaw” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Deep Learning Academy, przejdź na CoddyKit PRO. Kurs Deep Learning Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „Zakodować perceptron od podstaw”?
Zaimplementować neuron w kilku wierszach kodu Python Ćwiczysz Deep Learning Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Deep Learning Academy?
Nie wymagamy żadnego doświadczenia. Deep Learning Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 3 z 4.
Ile czasu zajmuje lekcja „Zakodować perceptron od podstaw”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Deep Learning Academy?
Tak. Każda lekcja Deep Learning Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Wagi, bias i suma ważona
- Funkcja schodkowa i decyzje liniowe
- Zakodować perceptron od podstaw
- Problem XOR: dlaczego jeden neuron nie wystarcza