In the early days of machine learning (before the first AI winter), networks like this were often implemented and trained in hardware: https://en.wikipedia.org/wiki/ADALINE That was the first thing that came to mind when I read "the smallest brain you can build ". Nowadays, that "small brain" would likely be built on a breadboard using op-amps instead.
The Smallest Brain You Can Build: A Perceptron in Python
71–80 of 86 posts
Re: The Smallest Brain You Can Build: A Perceptron in Python
#72Earlier quoted context omitted.
Amazing and anachronistic to see something like that from 1960. And then it makes me wonder why there wasn't more progress on neural nets being used for many things prior to the 21st century. (I haven't read the history of the AI winters but I have heard of them)
The first AI winter was largely triggered by Minsky in a book he published in 1969, which mathematically proved that single-layer perceptrons couldn't solve non-linear problems. Favorite quote: "Our intuitive judgment is that the extension [to multilayer systems] is sterile." Yet we had the computational power to run backpropagation in the 1960s and small Transformers in the 1970s (I'm the author of both): https://gi…
Re: The Smallest Brain You Can Build: A Perceptron in Python
#73I think it should be quite obvious that perceptrons are far from the smallest units that are capable of learning. They store many bytes of information, require a non-local update process, need numeric (i.e. symbolic) inputs and involve relatively complex computations. You can go much simpler. For example: https://medium.com/@VictorBanev/the-simplest-learning-machin... This is a description of a 5-line algorithm that…
Re: The Smallest Brain You Can Build: A Perceptron in Python
#74I think Karpathy's microgpt blogpost is the best in this genre in a long time, and it also includes a multi layer perceptron. It's a step up in the hierarchy, so reading both is helpful, of course. https://karpathy.github.io/2026/02/12/microgpt/
I'm not sure if I'd like to declare a best. There are so many different approaches and I think their ability to inform is cumulative, I like the ability of this article to do the tiny training runs in browser. It makes the point of a bias clear. Too many tutorials get sucked into the proof of zero times anything is zero. Everyone knows that. What you should show is where that mstters in the problem at hand. 3blue1bro…
Re: The Smallest Brain You Can Build: A Perceptron in Python
#75One day I'll write about my 1-liner physics engine... let gravity = setInterval( _ => { if (projectile.object3D.position.y > 0) projectile.object3D.position.y \*= .99 }, 100) Jokes aside I find that providing ridiculously short toy examples that provide the very limited foundation of a concept are extremely empowering in pedagogy. You "get" it right away because it "fits" in your mind, then you dare tinker with it an…
Re: The Smallest Brain You Can Build: A Perceptron in Python
#76Re: The Smallest Brain You Can Build: A Perceptron in Python
#77 import random
learning_rate = 0.1
EPOCHS = 50
NUM_INPUTS = 3
weights = [random.uniform(-1, 1) for _ in range(NUM_INPUTS)]
bias = random.uniform(-1, 1)
data = []
for _ in range(100):
inputs = [random.uniform(-1, 1) for _ in range(NUM_INPUTS)]
result = sum(inputs) > 0
data.append((inputs, result))
for epoch in range(EPOCHS):
for inputs, result in data:
weighted_sum = bias
for i in range(NUM_INPUTS):
weighted_sum += inputs[i] * weights[i]
prediction = weighted_sum > 0
if prediction != result:
error = int(result) - int(prediction)
for i in range(NUM_INPUTS):
weights[i] += learning_rate * error * inputs[i]
bias += learning_rate * error
print(f"Final weights: {[round(w, 3) for w in weights]}")
print(f"Final bias: {round(bias, 3)}")