Intermediate 25 min

Start with one neuron

Before layers, before GPUs, before frameworks—there is one neuron and three numbers: input, weight, bias.

raw_output = study_hours × weight + bias

Think of weight as how much study hours matter. Bias slides the whole decision boundary left or right.

Walk through with numbers

study_hours = 2
weight = 0.5
bias = -1

prediction = study_hours * weight + bias
print(prediction)  # 0.0

For 2 hours: 2 × 0.5 + (-1) = 0.0. That is the raw score. Not a probability yet—we fix that on the next page.

What if weight changes?

study_hoursweightbiasraw_output
20.5-10.0
21.0-11.0
20.2-1-0.6

Same input, different weight → different output. Training is mostly finding weights that make outputs match labels.

Interactive Diagram

This interactive diagram requires JavaScript to be enabled.

Diagram

Steps:

  1. Study hours enter as the input feature.
  2. Multiply by weight and add bias to get raw z.
  3. Later we pass z through sigmoid; for now it is just a number.

Try it in the browser

Edit the values and run. Watch how raw_output moves when you change weight or bias.

🐍 Python Single neuron forward pass
📟 Console Output
Run code to see output...

Exercise 1 — change the weight

Set weight = 1.0 (keep study_hours = 2, bias = -1).

Question: What is the new raw_output? Does a higher weight push the score up or down for the same study hours?

Answer

2 × 1.0 + (-1) = 1.0. Higher weight amplifies the input, so the raw score increases when study hours are positive.

Why bias exists

Weight alone ties the output to the input scaling through zero. Bias lets the model say “even with zero hours, my baseline is here.” Without bias, many real problems are awkward to fit.

You will see bias move during training on page 4—it often does a lot of the work early on.

Mental model check

  • Input = feature value (study hours)
  • Weight = importance of that feature
  • Bias = baseline shift
  • Raw output = not yet a probability; can be negative or greater than 1

Key takeaways

  1. One neuron is multiplication plus addition.
  2. Weights scale inputs; bias shifts the result.
  3. Changing weight changes the raw score even when input stays fixed.

Next: we squash the raw score with sigmoid and turn it into pass/fail.