惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
Hacker News: Ask HN
Hacker News: Ask HN
L
Lohrmann on Cybersecurity
PCI Perspectives
PCI Perspectives
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MyScale Blog
MyScale Blog
月光博客
月光博客
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
The GitHub Blog
The GitHub Blog
Webroot Blog
Webroot Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
TaoSecurity Blog
TaoSecurity Blog
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
F
Full Disclosure
U
Unit 42
Jina AI
Jina AI
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
T
Troy Hunt's Blog
腾讯CDC
T
Threatpost
H
Hacker News: Front Page
P
Palo Alto Networks Blog
博客园 - 聂微东
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
Help Net Security
Help Net Security
L
LINUX DO - 热门话题
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Spread Privacy
Spread Privacy

Hacker News

Introducing Claude Opus 4.7 Qwen Studio The Future of Everything is Lies, I Guess: Where Do We Go From Here? GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis Moving a large-scale metrics pipeline from StatsD to OpenTelemetry / Prometheus GitHub - Nightmare-Eclipse/RedSun: The Red Sun vulnerability repository GitHub - SethPyle376/hiraeth: Local AWS emulator focused on fast integration testing, with SQS support, SQLite-backed state, and a debug-friendly web UI. GitHub - macOS26/Agent: Any AI, replaces Claude Code, Cursor, OpenClaw. Over 18 LLM providers (Claude, OpenAI, Gemini, Ollama, Zai, HF, Qwen) wired into a native Mac app that writes code, builds Xcode projects, bumps versions, manages git, automates Safari, use AppleScript, JS or Accessibility, extend Agent! w/ MCP Servers, run tasks from your iPhone via Messages. YouTube now lets you turn off Shorts I Made a Terminal Pager Burgers | マクドナルド公式 Commands — HackerNews CLI documentation ChatGPT for Excel PiCore - Raspberry Pi Port of Tiny Core Linux Live Nation illegally monopolized ticketing market, jury finds Google Broke Its Promise to Me. Now ICE Has My Data. Founding Engineer at Adaptional | Y Combinator CRISPR takes important step toward silencing Down syndrome’s extra chromosome GitHub - saffron-health/libretto: The AI toolkit for building reliable browser automations US v. Heppner (S.D.N.Y. 2026) no attorney-client privilege for AI chats [pdf] Unexpected €54k billing spike in 13 hours: Firebase browser key without API restrictions used for Gemini requests Retrofitting JIT Compilers into C Interpreters IPv6 – Google The Accursèd Alphabetical Clock Cybersecurity Looks Like Proof of Work Now Fragments: April 14 Cal.com Goes Closed Source: Why AI Security Is Forcing Our Decision | Cal.com - Scheduling Software for Online Bookings Laravel raised money and now injects ads directly into your agent When moving fast, talking is the first thing to break Too much Discussion of the XOR swap trick – Heather Cafe Introduction to Spherical Harmonics for Graphics Programmers The Grand Line Building a Z-Machine in the worst possible language High-Level Rust: Getting 80% of the Benefits with 20% of the Pain GitHub - duguyue100/midnight-captain: Inspired by Midnight Commander, tailored to my taste. How to build a `git diff` driver · Jamie Tanna | Software Engineer Center for Responsible, Decentralized Intelligence at Berkeley The Local Universe’s Expansion Rate Is Clearer Than Ever, but Still Doesn’t Add Up - A new synthesis of astronomical measurements confirms a persistent mismatch that could point to physics beyond current models The air throughout our homes is infused with microplastics. But there are things you can do to breathe less of them The disturbing white paper Red Hat is trying to erase from the internet – OSnews The Future of Everything is Lies, I Guess: Annoyances ‘Abhorrent’: the inside story of the Polymarket gamblers betting millions on war Productive procrastination — Max van IJsselmuiden maps, territory and LMs 447 Terabytes per Square Centimetre at Zero Retention Energy: Non-Volatile Memory at the Atomic Scale on Fluorographane Show HN: Pardonned.com – A searchable database of US Pardons 20 Years on AWS and Never Not My Job The Seasons are Wrong Artemis II crew splashes down near San Diego after historic moon mission We gave an AI a 3 year retail lease in SF and asked it to make a profit | Andon Labs How a dancer with ALS used brainwaves to perform live On filing the corners off my MacBooks Installing every* Firefox extension OpenClaw’s memory is unreliable, and you don’t know when it will break Steve Blank Nowhere Is Safe Chimpanzees in Uganda locked in vicious 'civil war', say researchers watgo - a WebAssembly Toolkit for Go linux/Documentation/process/coding-assistants.rst at master · torvalds/linux GitHub - callumlocke/json-formatter: Makes JSON easy to read. Founding Product Engineer at Bild AI | Y Combinator A compelling title that is cryptic enough to get you to take action on it GitHub - Keychron/Keychron-Keyboards-Hardware-Design: Industrial design files for Keychron keyboards and mice. 100+ models with CAD assets in STEP, DXF, DWG, and PDF. Source-available, with commercial use allowed for original compatible accessories within the license terms. [ANNOUNCE] WireGuardNT v0.11 and WireGuard for Windows v0.6 Released 1D-Chess Helium Is Hard to Replace Cooperative Vectors Introduction | Evolve Keeping a Postgres queue healthy — PlanetScale Our response to the Axios developer tool compromise Do Americans read print books, e-books or audiobooks more? The Zettelkasten Method in Obsidian: A Practical Setup Guide Artemis II Is Competency Porn and We Are Starving For It WeakC4 Flight Viz — Cockpit View A Mexican surveillance giant you’ve never heard of is now watching the U.S. border Surelock: Deadlock-Free Mutexes for Rust RISC-V 101 – what is it and what does it mean for Canonical? | Ubuntu The Problem That Built an Industry How Much Linear Memory Access Is Enough? | Solidean Investigating Split Locks on x86-64 Simplest hash functions Sybilproof reputation mechanisms (2005) [pdf] What is a property? How Complex is my Code? Static code analysis in Kotlin — tools overview Toffoli gates are all you need PGLite evangelism dcmake: a new CMake debugger UI Clojure on Fennel part one: Persistent Data Structures Fragments: April 2 Python Release Python install manager 26.1 The Life and Death of the Book Review - Liberties Introducing Database Traffic Control — PlanetScale Bitcoin miners are losing $19,000 on every BTC produced as difficulty drops 7.8% God sleeps in the minerals Building slogbox Apple Silicon and Virtual Machines: Beating the 2 VM Limit Who was “Not Even Wrong” first? Pokemon Evolution Vs Darwinian Evolution The APL Programming Language Source Code
The Smallest Brain You Can Build
Devarsh Ranpara · 2026-06-08 · via Hacker News

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

Before a machine decides anything, let us watch a human decide. Meet John Doe. He has a job offer, and he must answer one question: should he take it?

John does not flip a coin. He weighs things. Some factors matter to him more than others.

Factor (input)ValueHow much John cares (weight)
Extra payhigha lot
Stays in the same cityno, he must movea lot

John multiplies each factor by how much he cares about it, then adds everything up. If the total is high enough, he says yes. If not, he says no.

That is a perceptron. The factors are the inputs. How much he cares is the weight. And “high enough” is a threshold he carries in his head. Hold on to that threshold. Later we will give it a name: the bias.

Two inputs, Pay and Same city, each multiplied by a weight, summed together with a bias, and turned into a single yes-or-no output.w₁w₂+ bPaySamecityΣtake the offer?Yes / No
How John Doe decides: each input is multiplied by a weight, the results are summed with a bias, and the total becomes one yes-or-no answer.

The simplest possible decision: is this number positive?

Let us shrink the problem until almost nothing is left. One input. One question.

Is this number positive?

That is it. Feed the machine a number. It should answer True for positive and False for negative.

The machine makes its guess like this:

prediction = (weight * value + bias) > 0

Multiply the input by the weight, add the bias, and check if the result is above zero. If yes, it predicts True. If no, it predicts False. This little formula is the classifier, also called the decision function.

At the start, the weight and bias are just random numbers. So the machine guesses badly. Now comes the only clever part: it learns from its mistakes.

if prediction != result:
    error = result - prediction      # True - False = 1, False - True = -1
    weight += learning_rate * error * value
    bias   += learning_rate * error

When the guess is wrong, we nudge the weight and bias in the right direction. The error tells us which way to nudge. The learning rate decides how big each nudge is. We do this for every example, then repeat the whole pass again. One full pass over the data is called an epoch. Repeating epochs is training.

Here is that exact machine. Press Train and watch it learn. Each green dot is a positive number (True), each red dot is negative (False), and the blue dashed line is where it has decided to split them.

epoch 0 weight 0 bias 0 boundary  accuracy 0%

It snaps into place almost immediately. Look at the readout: the boundary lands right around 0, and the bias settles near 0 too.

That is not an accident. For this problem, we never needed the bias at all. Which is strange, because bias is supposed to be important. To see why it matters, we need a harder question.

What is a decision boundary?

That blue line has a name: the decision boundary. It is the exact point where the machine flips from saying False to saying True.

We can compute it. The boundary sits where w · x + b = 0. Solve for x:

decision_boundary = -bias / weight

For “is this number positive,” the boundary should be at 0. And it is. Now watch what happens when the right answer is not at zero.

Why do we need bias? The student-pass example

New problem. Same machine. We give it exam scores from 0 to 100, and we ask:

Did the student pass?

The rule is simple: a score of 50 or higher passes. So the decision boundary should sit at 50, not at 0.

Let us try to solve it the way we solved the last one, using the weight only. In the demo below, turn off “Use bias” and press Train.

epoch 0 weight 0 bias 0 boundary  accuracy 0%

Use bias

Watch the accuracy. It climbs to around 50 percent and then gets stuck. It cannot do better, no matter how long you train it.

Here is why. With no bias, the formula is just weight * score. Every exam score is a positive number. So if the weight is positive, the machine calls every student a pass. If the weight is negative, it fails everyone. The boundary is glued to 0, and it cannot move. A line forced through zero simply cannot separate “below 50” from “50 and up.”

Now turn “Use bias” back on and press Train again. The accuracy climbs all the way to 100 percent, and the boundary slides over and parks near 50.

That is the whole job of the bias. The weight sets the steepness. The bias moves the boundary left or right so it can sit wherever the answer actually is. Remember decision_boundary = -bias / weight. With a bias, the boundary can be anything. Without one, it is stuck at zero forever.

The one sentence to remember: when your inputs sit far from zero, you need a bias to move the line to them.

How does a perceptron learn? Epochs and learning rate

You saw two dials while training: epochs and learning rate.

An epoch is one full pass over all the data. The machine rarely gets everything right in a single pass, so we go again, and again. More epochs means more chances to fix mistakes. That is why accuracy climbs as you keep training.

The learning rate is the size of each correction. In the code it is the learning_rate multiplier:

weight += learning_rate * error * value

Small steps are careful but slow. Big steps are fast but can overshoot and bounce around. Choosing it well is part of the craft. Here we used 0.1, which is gentle enough to stay stable.

Why do we normalize data?

There is a quiet problem hiding in the pass example. Look at that update line again:

weight += learning_rate * error * value

The correction is multiplied by value. For exam scores, value can be as large as 100. So a single wrong guess can throw the weight by a huge amount. The machine still learns, but it lurches around instead of settling smoothly.

The fix is normalization: shrink the inputs to a small, tidy range before training. The simplest version is to divide every score by the largest possible score, so 0 to 100 becomes 0 to 1.

In the demo below, first press Train with normalization off and watch the accuracy line jump around on its way up. Then turn “Normalize data” on, reset, and train again. Same machine, same answer, but it gets there in a fraction of the epochs, and the climb is smooth.

epoch 0 weight 0 bias 0 boundary  accuracy 0%

Normalize data

One honest note. With a single input like this, normalization mostly buys you speed and calm. It becomes essential when your inputs live on very different scales. Think back to John Doe: his pay was measured in thousands of dollars, but “same city” was just a 0 or a 1. Without normalization, the dollars would drown out everything else, and the machine would basically ignore the city. Putting both on the same scale lets each factor get a fair say. (Dividing by the max is the easy version; a common general method is to subtract the mean and divide by the spread, called standardization.)

The full perceptron in Python

Here is the complete program for “is this number positive,” with nothing hidden. It is short enough to read in one sitting.

import random

learning_rate = 0.1
EPOCHS = 100

weight = random.uniform(-1, 1)
bias   = random.uniform(-1, 1)

# positive numbers are True, negative numbers are False
data  = [(i * 0.1, True)  for i in range(1, 501)]
data += [(i * 0.1, False) for i in range(-500, 0)]
random.shuffle(data)

for epoch in range(EPOCHS):
    for value, result in data:
        prediction = (weight * value + bias) > 0
        if prediction != result:
            error = result - prediction          # +1 or -1
            weight += learning_rate * error * value
            bias   += learning_rate * error

decision_boundary = -bias / weight
print(f"weight = {weight:.3f}")
print(f"bias   = {bias:.3f}")
print(f"decision boundary = {decision_boundary:.3f}")

To turn this into the student-pass machine, you change two things: make the data exam scores with result = score >= 50, and, if you want to feel the pain of a missing bias, freeze the bias at 0. Everything else stays the same.

Acknowledgments

The core inspiration for this post came from the fantastic video ChatGPT is made from 100 million of these [The Perceptron] by Welch Labs. If you are a visual learner and want to see the rich history and hardware behind these concepts, I highly recommend watching it!

What’s next?

You just built a working perceptron. It takes an input, weighs it, adds a bias, and decides. It learns from its own mistakes, one epoch at a time.

A single neuron can only draw one straight line. The magic starts when you stack them: the output of one neuron becomes the input of the next. Layer enough of them together and you get a neural network that can learn shapes far more tangled than a single line. But every one of those neurons is doing exactly what you just watched. A weight, a bias, a decision.

If you want the non-technical story of how I ended up writing code in Canada at all, I wrote about it here: The Outsider Who Shipped Anyway.

Thanks for building this with me. Now go change the numbers and break it. That is the fastest way to learn.