Skip to content
Tech News
← Back to articles

The Smallest Brain You Can Build: A Perceptron in Python

read original more articles

A perceptron explained from scratch in Python, with interactive demos. Learn weights, bias, the decision boundary, epochs, learning rate, and why we normalize data.

A perceptron is the smallest brain you can build. One number goes in. One yes-or-no answer comes out. That is the whole thing.

It sounds too simple to matter. But this tiny idea is the seed of every neural network running today. In this post we build a perceptron from scratch in Python, and we watch it learn, live, in your browser. No heavy math. No big libraries. Just a weight, a bias, and a loop.

I am not a native English speaker, and I am still learning this field myself. So I will explain it the way I needed someone to explain it to me. Slowly, and from the ground up.

What is a perceptron?#

In 1958, a researcher named Frank Rosenblatt built a machine he called the perceptron.

It was inspired by a single brain cell, a neuron. A neuron takes in signals, and if those signals are strong enough, it fires. Rosenblatt copied that idea in math:

output = 1 if (w · x + b) > 0 0 otherwise

Here x is the input, w is the weight, and b is the bias. Do not worry about those words yet. We will meet each of them by building something real.

Think like a human first#

... continue reading