Understanding AI · lesson 25 of 60 · about 5 minutes
Inputs and Weights
Meet the artificial neuron: the tiny building block behind face unlock and chatbots.
What you'll learn
- Describe what a neuron's inputs are
- Explain what a weight does
- Read a neuron's weights to see what it cares about
A very simple idea
An artificial neuron was loosely inspired by brain cells, but it's really just a little bit of maths.
It takes in some numbers, its inputs. Each input has a weight: a number saying how much that input matters. A big weight means the input counts for a lot; a weight near 0 means it hardly counts; a negative weight means it counts against.
Should I go to the park?
Imagine a neuron deciding whether to go to the park. Inputs: is it sunny (1 or 0), are friends going (1 or 0), is it raining (1 or 0). Weights might be 2 for sunny, 3 for friends and -4 for raining. Friends matter most, and rain counts strongly against.
Each input times its weight: how much it pushes the decision. `*` multiplies.
sunny, friends, raining = 1, 1, 0
w_sunny, w_friends, w_raining = 2, 3, -4
print(sunny * w_sunny)
print(friends * w_friends)
print(raining * w_raining)Output
2
3
0Tip
A weight near 0 means an input hardly matters; a negative weight pushes against.
Now try it yourself
This lesson is free in Codiqo, with 6 questions on what you just read. You can only learn to code by writing code, so it ends with a short program you write yourself, which we run and check straight away.