Programe un perceptrón desde cero
Una neurona en unas pocas líneas de Python
Programe un perceptrón desde cero es una lección gratuita de Deep Learning Academy en CoddyKit. Esta es la lección 3 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Deep Learning Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Deep Learning Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en 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.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. ✅
Preguntas frecuentes
¿La lección «Programe un perceptrón desde cero» es gratis?
Sí — el texto completo de «Programe un perceptrón desde cero» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Deep Learning Academy, actualiza a CoddyKit PRO. El curso de Deep Learning Academy incluye 4 lecciones en total.
¿Qué aprenderé en «Programe un perceptrón desde cero»?
Una neurona en unas pocas líneas de Python Practicas Deep Learning Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Deep Learning Academy?
No se requiere experiencia previa. Deep Learning Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 3 de 4.
¿Cuánto tiempo toma la lección «Programe un perceptrón desde cero»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Deep Learning Academy?
Sí. Cada lección de Deep Learning Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Pesos, sesgo y suma ponderada
- La función escalón y las decisiones lineales
- Programe un perceptrón desde cero
- El problema XOR: por qué una neurona no basta