Codiqo

Understanding AI · lesson 26 of 60 · about 6 minutes

Adding It Up

A neuron multiplies each input by its weight and adds everything up, plus one extra number called the bias.

What you'll learn

  • Work out a neuron's weighted total
  • Explain what the bias does
  • Write the total as one line of Python

The weighted total

The neuron's job is simple: multiply each input by its weight, then add them all up. That's called the weighted sum.

Then it adds one more number, the bias. The bias is like the neuron's mood before it looks at anything: a negative bias makes it harder to say yes, a positive bias makes it easier.

The park neuron on a sunny day with friends going and no rain. Its bias is -1.

sunny, friends, raining = 1, 1, 0
w_sunny, w_friends, w_raining = 2, 3, -4
bias = -1
total = sunny * w_sunny + friends * w_friends + raining * w_raining + bias
print(total)

Output

4

Tip

2 + 3 + 0, then the bias of -1: 4. That's the neuron's total.

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.