0Pricing
Deep Learning Academy · Aula

Programe um Perceptron do Zero

Um neurônio em poucas linhas de Python

Programe um Perceptron do Zero é uma aula grátis de Deep Learning Academy no CoddyKit. Esta é a aula 3 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Deep Learning Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Deep Learning Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

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. ✅

Perguntas Frequentes

A aula “Programe um Perceptron do Zero” é grátis?

Sim — o texto completo de “Programe um Perceptron do Zero” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Deep Learning Academy, atualize para CoddyKit PRO. O curso de Deep Learning Academy inclui 4 aulas no total.

O que vou aprender em “Programe um Perceptron do Zero”?

Um neurônio em poucas linhas de Python Você pratica Deep Learning Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Deep Learning Academy?

Nenhuma experiência prévia é necessária. Deep Learning Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 3 de 4.

Quanto tempo leva a aula “Programe um Perceptron do Zero”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Deep Learning Academy?

Sim. Cada aula de Deep Learning Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Pesos, Viés e a Soma Ponderada
  2. A Função Degrau e Decisões Lineares
  3. Programe um Perceptron do Zero
  4. O Problema XOR: Por Que Um Neurônio Não Basta
← Voltar para Deep Learning Academy