Skip to content

Expert: deep learning and AI · Neural networks and deep learning · topic 43 of 62 · 30 min

The artificial neuron

Explanation

An artificial neuron multiplies each input by a weight, adds them up with a bias, and passes the total through an activation function to produce an output. The perceptron is the simplest neuron: it outputs 1 or 0 and learns by nudging its weights after every mistake. One neuron can only draw a straight dividing line, which is why we need networks of them.

Why start with one neuron?

Deep learning powers face unlock, speech-to-text in Indian languages, photo search and large language models. Under all of them is one small building block repeated millions of times: the artificial neuron. If you understand one neuron, the rest is about connecting many of them and training them together.

What a neuron computes

  1. Take the inputs x₁, x₂, … (for example, a loan applicant's income and existing debt, already scaled).
  2. Multiply each input by its weight w₁, w₂, …. A weight says how important that input is, and whether it pushes the output up (positive) or down (negative).
  3. Add them up and add a bias b: z = w₁x₁ + w₂x₂ + … + b. The bias shifts the threshold, like a starting score.
  4. Pass z through an activation function to get the output. The step function outputs 1 if z > 0 and 0 otherwise; the sigmoid outputs a value between 0 and 1.
python
def neuron(inputs, weights, bias):
    z = sum(x * w for x, w in zip(inputs, weights)) + bias
    return 1 if z > 0 else 0

print(neuron([1, 1], [0.6, 0.6], -1.0), neuron([1, 0], [0.6, 0.6], -1.0))
Shows 1 0. With these weights the neuron fires only when both inputs are 1: it computes logical AND.
Think of it like this: A neuron is like a selection committee deciding on a scholarship. Each committee member (input) gives a score, some members' opinions count more (weights), the college has a base requirement (bias), and if the weighted total crosses the line, the answer is yes.

Inspired by the brain, but not a brain

The idea came from biological neurons, which fire when enough signal arrives from their neighbours. Artificial neurons are a very loose, simplified mathematical version. Modern deep learning has little to do with real brain biology; think of it as a flexible maths function, not a digital brain.

The perceptron learning rule

The perceptron (Frank Rosenblatt, 1958) learns from labelled examples. Start with weights of zero. For each example, predict; if the prediction is wrong, adjust: w = w + learning_rate × (target − prediction) × x, and b = b + learning_rate × (target − prediction). If the prediction was too low (target 1, predicted 0), the weights of the active inputs go up; if too high, they go down. Repeat over the data for several epochs.

The XOR problem

A single neuron can only separate classes with one straight line (a hyperplane in more dimensions). AND and OR can be separated that way. XOR ("exactly one of the two is 1") cannot: no single line puts (0,1) and (1,0) on one side and (0,0) and (1,1) on the other. This limitation, highlighted by Minsky and Papert in 1969, was solved by stacking neurons into layers with non-linear activations, which is the next topic.

Common mistakes

  • Forgetting the bias. Without it, the dividing line must pass through the origin, which limits what the neuron can learn.
  • Feeding unscaled inputs (₹ incomes beside ages), which makes learning slow and unstable.
  • Thinking more epochs always fix a perceptron. If the data is not linearly separable, it never settles.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

The artificial neuron · 1/6

The neuron

Every neural network is built from one small part: the artificial neuron.

Prefer a video by a teacher? Find free videos on “perceptron artificial neuron explained weights bias activation” on YouTube ↗

In real life: A first check on loan applications

Logistic regression, used in many lending scorecards, is mathematically a single neuron with a sigmoid activation: weighted inputs plus a bias, squeezed into a probability. When data scientists say "a neural network is many logistic regressions stacked together", they mean exactly this building block.

python
import math

def sigmoid_neuron(inputs, weights, bias):
    z = sum(x * w for x, w in zip(inputs, weights)) + bias
    return 1 / (1 + math.exp(-z))

print(round(sigmoid_neuron([0.8, 0.2], [2.0, -3.0], -1.1), 3))
Shows 0.475: a 47.5% score for this (scaled) applicant.

Practice (0/2 done)

Task 1 · Code · Python

Write step_neuron(inputs, weights, bias) that returns 1 if Σ(input × weight) + bias > 0, otherwise 0.

Task 2 · Code · Python

Train a perceptron. Write train_perceptron(data, lr, epochs) where data is a list of ((x1, x2), target). Start with w = [0.0, 0.0] and b = 0.0. In each epoch go through data IN ORDER: pred = 1 if w1·x1 + w2·x2 + b > 0 else 0; then w1 += lr·(target − pred)·x1, w2 += lr·(target − pred)·x2, b += lr·(target − pred). Return ([round(w1, 4), round(w2, 4)], round(b, 4)).

Quick quiz

Question 1

1.What does a weight tell you in a neuron?

Question 2

2.What is the job of the bias?

Question 3

3.Inputs [1, 2], weights [0.5, −1], bias 1. What is z?

Question 4

4.Why can a single perceptron not learn XOR?

Question 5

5.In the perceptron rule, what happens when the prediction is correct?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What does a weight tell you in a neuron?

Answer: How strongly, and in which direction, an input affects the output

Big positive weights push the output up; negative ones push it down.

What is the job of the bias?

Answer: To shift the threshold, like a starting score

The bias lets the dividing line move away from the origin.

Inputs [1, 2], weights [0.5, −1], bias 1. What is z?

Answer: −0.5

0.5 × 1 + (−1) × 2 + 1 = −0.5.

Why can a single perceptron not learn XOR?

Answer: XOR's classes cannot be separated by one straight line

One neuron draws one line; XOR needs a non-linear boundary.

In the perceptron rule, what happens when the prediction is correct?

Answer: Nothing changes, because target − prediction is 0

Updates only happen on mistakes.

A dense layer goes from 100 inputs to 50 neurons. How many parameters?Related

Answer: 5,050

100 × 50 weights + 50 biases.

From Layers, activations and the forward pass

Which optimiser adapts the step size for each weight and is a common default?Related

Answer: Adam

Adam keeps running averages of gradients per weight.

From Training: loss, backpropagation and optimisers

In scikit-learn, where are the learned weights of a LinearRegression model?Related

Answer: model.coef_ and model.intercept_

Fitted attributes end with an underscore: coef_ and intercept_.

From Linear regression and least squares

Which variant updates the weights after each small group of examples, such as 64?Related

Answer: Mini-batch gradient descent

Mini-batch is the standard in deep learning.

From Gradient descent: learning step by step

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 4 more topics in “Neural networks and deep learning” before its exam: Layers, activations and the forward pass, Training: loss, backpropagation and optimisers, CNNs, RNNs and transformers at a glance, Deep learning tools and hardware.
  2. Module 9 exam: Neural networks and deep learning · 12 questions · 25 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, NLP, embeddings and large language models. 62 topics left in the course before the final exam.

← Previous: Feature selection, leakage and pipelines