1. Home
  2. AI & Machine Learning
  3. Neural Network (Forward Pass)

Neural Network (Forward Pass)

See exactly how a neural network turns inputs into a prediction — neuron by neuron, weight by weight — in a 3D network you can rotate.

Interactive 3DBeginner15 min readAI/MLUpdated

Drag to rotate · Right-drag to pan · Click, then scroll to zoom · Space play · Left arrowRight arrow step

What's happening

A neural network is layers of simple "neurons". Each neuron multiplies its inputs by weights (blue = positive, red = negative, thicker = stronger), adds them up, and passes the result on. Press Run forward pass.

Pseudocode

  1. for each layer L (left → right):
  2. for each neuron j in L:
  3. z ← Σ ( w[j][i] × a[i] ) + b[j] // weighted sum
  4. a[j] ← ReLU(z) = max(0, z) // activation
  5. output scores → softmax → probabilities
  6. prediction ← class with highest probability
Read this model as text · 12 steps

One run of the model above, written out step by step. Useful with a screen reader, on a slow connection, or for quick revision. The values may differ from the run on your screen.

  1. A neural network is layers of simple "neurons". Each neuron multiplies its inputs by weights (blue = positive, red = negative, thicker = stronger), adds them up, and passes the result on. Press Run forward pass.
  2. Inputs are scaled to 0–1: study 8 h → 0.8, sleep 7 h → 0.7, attendance 90% → 0.9. Signals flow left → right.
  3. z = 2×0.8 + 0.3×0.7 + 0.5×0.9 − 0.6 = 1.66 → ReLU → 1.66. This neuron learned to detect "hard work".
  4. z = 0.2×0.8 + 1.8×0.7 + 0.2×0.9 − 0.8 = 0.8 → ReLU → 0.8. This neuron learned to detect "well rested".
  5. z = 0.4×0.8 + 0.1×0.7 + 2×0.9 − 0.9 = 1.29 → ReLU → 1.29. This neuron learned to detect "shows up".
  6. z = -1.5×0.8 + -0.5×0.7 + -1.2×0.9 + 1.2 = -1.43 → ReLU → 0. Negative sums are cut to 0: this neuron stays silent. This neuron learned to detect "risk".
  7. z = 1.2×1.66 + 0.4×0.8 + 0.8×1.29 + -1×0 − 0.1 = 3.24 → ReLU → 3.24.
  8. z = 0.3×1.66 + 1×0.8 + 0.2×1.29 + -0.5×0 + 0 = 1.56 → ReLU → 1.56.
  9. z = -0.6×1.66 + -0.4×0.8 + -0.6×1.29 + 1.5×0 + 0.1 = -1.99 → ReLU → 0. Negative sums are cut to 0: this neuron stays silent.
  10. Score for Pass: 1×3.24 + 0.5×1.56 + -1.2×0 + 0 = 4.02.
  11. Score for Fail: -0.8×3.24 + -0.3×1.56 + 1.4×0 + 0.4 = -2.66.
  12. Softmax turns the scores into probabilities that add up to 100%: Pass 100%, Fail 0%. Prediction: PASS. Change the sliders and run it again!

Try this in the 3D model

  • Press Run forward pass and read how each neuron's number is calculated.
  • Drag the Study hours slider from 0 to 10 and watch the Pass probability change live.
  • Try the Struggling preset. Which hidden neuron lights up? (Hint — the "risk" detector.)
  • Rotate the network and find the thickest red line. What does a strong negative weight do?

The big idea

A neural network is a function that turns inputs (numbers) into outputs (a prediction). It is built from many tiny units called neurons, arranged in layers:

  • an input layer — the data we feed in,
  • one or more hidden layers — where patterns are detected,
  • an output layer — the answer.

The network in the 3D model answers a toy question: “Will this student pass the exam?”, from three inputs: study hours, sleep hours and attendance.

One neuron, up close

Every neuron does the same two small steps:

1. Weighted sum. Multiply each input by a weight, add them up, and add a bias:

z = w₁·x₁ + w₂·x₂ + w₃·x₃ + b

A weight says how important an input is. A big positive weight means “this input pushes me up a lot”; a negative weight means “this input pushes me down”. In the model, blue lines are positive weights, red lines are negative, and thicker means stronger. The bias shifts the result up or down, like a threshold.

2. Activation. Pass z through an activation function. We use ReLU:

ReLU(z) = max(0, z)

Negative sums become 0 (the neuron stays “silent”), positive sums pass through. Without this non-linear step, stacking layers would be pointless — the whole network would collapse into one big linear equation.

The forward pass, layer by layer

Data flows left to right:

  1. Input layer: the three inputs, scaled to 0–1 (e.g. 8 study hours → 0.8).
  2. Hidden layer 1: each of the 4 neurons computes its weighted sum + ReLU. With our hand-picked weights they act like detectors for “hard work”, “well rested”, “shows up” and “risk”.
  3. Hidden layer 2: combines those detectors into higher-level signals.
  4. Output layer: produces one raw score per class (Pass, Fail).
  5. Softmax turns the scores into probabilities that add up to 100%:
P(class i) = e^(score i) / Σ e^(score j)

The class with the highest probability is the prediction. Press Run forward pass in the model to see every one of these numbers calculated.

Code (NumPy)

import numpy as np

def relu(z):
    return np.maximum(0, z)

def softmax(z):
    e = np.exp(z - z.max())          # subtract max for numerical stability
    return e / e.sum()

# weights and biases (the same ones as the 3D model)
W1 = np.array([[2.0, 0.3, 0.5], [0.2, 1.8, 0.2], [0.4, 0.1, 2.0], [-1.5, -0.5, -1.2]])
b1 = np.array([-0.6, -0.8, -0.9, 1.2])
W2 = np.array([[1.2, 0.4, 0.8, -1.0], [0.3, 1.0, 0.2, -0.5], [-0.6, -0.4, -0.6, 1.5]])
b2 = np.array([-0.1, 0.0, 0.1])
W3 = np.array([[1.0, 0.5, -1.2], [-0.8, -0.3, 1.4]])
b3 = np.array([0.0, 0.4])

x = np.array([0.8, 0.7, 0.9])        # study 8h, sleep 7h, attendance 90%

a1 = relu(W1 @ x + b1)               # hidden layer 1
a2 = relu(W2 @ a1 + b2)              # hidden layer 2
p  = softmax(W3 @ a2 + b3)           # output probabilities

print("P(pass) = %.2f, P(fail) = %.2f" % (p[0], p[1]))

W1 @ x is a matrix–vector multiplication — it computes all four weighted sums of layer 1 in one go. That is why neural networks run so well on GPUs, which are built for exactly this kind of maths.

But where do the weights come from?

In our demo the weights were chosen by hand so you can understand each neuron. In real life nobody sets them manually. A network starts with random weights and learns them from examples:

  1. Run the forward pass (what you see here) to get a prediction.
  2. Measure the error with a loss function.
  3. Backpropagation uses the chain rule to compute the gradient of the loss with respect to every weight.
  4. Gradient descent nudges every weight a little in the downhill direction.
  5. Repeat over thousands of examples.

After training, hidden neurons usually detect useful patterns on their own — edges and shapes in images, or word meanings in text.

Key vocabulary

Term Meaning
Weight How strongly one neuron’s output influences the next neuron
Bias A constant added to the weighted sum (a threshold)
Activation function The non-linear step: ReLU, sigmoid, tanh…
Layer A group of neurons that work in parallel
Forward pass Computing the output from the input
Backpropagation Computing how each weight affected the error
Epoch One pass over the entire training dataset

Where are neural networks used?

Image recognition, speech-to-text, translation, recommendation systems, self-driving cars, and the large language models behind modern AI chatbots — which are huge networks with billions of weights, all built from the simple neuron you just watched.

Common misunderstandings

  • “Neurons store facts.” They don’t — knowledge is spread across many weights.
  • “More layers always means better.” Deeper networks need more data and careful training.
  • “The output probability is certainty.” A network can be confidently wrong, especially on inputs unlike its training data.

Complexity at a glance

Case / operationTimeWhy
Forward pass (one input)O(total weights)Every weight is used once — one multiply and one add.
Dense layer with n inputs and m neuronsO(n · m)This is a matrix–vector multiplication.
Extra spaceO(total weights)

Quick check

Test yourself — pick an answer to see if you got it.

1. What does a single artificial neuron compute before its activation function?

2. What is ReLU(−2.5)?

3. Why does the output layer use softmax?

4. During training, what does the network actually learn?

Saved in this browser.
Spotted a mistake or a bug in the 3D model?

Report a mistake

in Neural Network (Forward Pass). Thank you — every report makes the lesson better for the next reader.

We'll also include a link to the step of the 3D model you're on and your browser type, so we can reproduce it.