0Pricing
Deep Learning Academy · Урок

Напишите перцептрон с нуля

Нейрон в нескольких строках Python

«Напишите перцептрон с нуля» — бесплатный урок Deep Learning Academy на CoddyKit. Это урок 3 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения 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.0

Predict 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 0

Measure 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 - prediction

The 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 * error

The 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.1

One 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/7) и разблокировать остальной курс Deep Learning Academy, подпишись на CoddyKit PRO. Курс Deep Learning Academy содержит 4 уроков всего.

Чему я научусь в уроке «Напишите перцептрон с нуля»?

Нейрон в нескольких строках Python Ты практикуешь Deep Learning Academy с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.

Нужен ли мне опыт, чтобы начать Deep Learning Academy?

Предыдущий опыт не требуется. Deep Learning Academy на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 3 из 4.

Сколько времени занимает урок «Напишите перцептрон с нуля»?

Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.

Можно ли писать и запускать код в этом уроке Deep Learning Academy?

Да. Каждый урок Deep Learning Academy включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.

Все уроки этого курса

  1. Веса, смещение и взвешенная сумма
  2. Ступенчатая функция и линейные решения
  3. Напишите перцептрон с нуля
  4. Проблема XOR: почему одного нейрона недостаточно
← Назад к Deep Learning Academy