Forward Propagation

What Is Forward Propagation?

Forward propagation is the process of moving data through a neural network to produce an output. It is how a neural network makes a prediction.

01

Input data enters the network

02

Passes through the input layer

03

Moves through hidden layers

04

Reaches the output layer

05

A prediction is produced

The data moves forward through the network one layer at a time.

Why Forward Propagation Matters

Forward propagation matters because every neural network prediction starts with it. Before a model can calculate error or update weights, it first needs to make a prediction.

Forward Propagation Answers

Given this input, what does the model predict?

  • Email input → Spam or Not Spam
  • Image input → Cat, Dog, or Bird
  • House data input → House price
  • Text input → Next word or token

Forward Propagation in the Training Process

Forward propagation is one step in the full training cycle. It creates the prediction that will later be compared with the correct answer.

01

Model receives input data

02

Forward propagation produces a prediction

03

Loss function measures the error

04

Backpropagation sends error backward

05

Weights are updated

06

The process repeats

Input Data

Input data is the information given to the neural network. It usually comes from features in the dataset.

Input Examples

Spam Detection — Email length, number of links, suspicious words, sender reputation

House Price Prediction — Square footage, bedrooms, bathrooms, location score

Image Classification — Pixel values

Input Layer

The input layer receives the original data. It passes input values into the rest of the network.

House Price Model — Input Layer

Square footage — 2000

Bedrooms — 3

Bathrooms — 2

Location score — 8

These values move forward into the next layer.

Weights

Weights are learned numbers that control how strongly inputs affect the next layer. During forward propagation, inputs are multiplied by weights.

Example

Input — 3

Weight — 4

Input × Weight — 3 × 4 = 12

The weight controls how much influence the input has.

Bias

A bias is a learned number added to the weighted sum. It gives the model more flexibility.

Formula

Neuron value = weighted sum + bias

Weighted sum — 20

Bias — 5

Neuron value — 20 + 5 = 25

Weighted Sum

A weighted sum is the result of multiplying inputs by weights and adding them together.

Formula

Weighted Sum = input1 × weight1 + input2 × weight2 + input3 × weight3

Inputs — 2, 4, 6   Weights — 3, 1, 2

Calculation — 2×3 + 4×1 + 6×2 = 6 + 4 + 12 = 22

Activation Function

An activation function transforms the neuron value before sending it forward. Activation functions help neural networks learn non-linear patterns.

Common Activation Functions
  • ReLU
  • Sigmoid
  • Tanh
  • Softmax

Without activation functions, neural networks behave more like simple linear models.

Neuron Output

A neuron output is the result after the activation function is applied. This output can become input for the next layer.

01

Receive inputs

02

Multiply by weights

03

Add weighted values together

04

Add bias

05

Apply activation function → output

Hidden Layers

Hidden layers are layers between the input layer and output layer. Each hidden layer transforms the data.

Image Model Example

Early Hidden Layers — Detect edges and colors

Middle Hidden Layers — Detect shapes and textures

Later Hidden Layers — Detect object parts

Purpose: Build complex patterns from simple inputs.

Output Layer

The output layer produces the final prediction. The type of output depends on the task.

Output Examples

Binary Classification — Spam or Not Spam

Multi-Class Classification — Cat, Dog, or Bird

Regression — Predicted house price

Text Generation — Next token or word

Forward Propagation Step by Step

01

Input values enter the input layer

02

Inputs are multiplied by weights

03

Weighted values are added together

04

Bias is added

05

Activation function is applied

06

Output moves to the next layer

07

Steps repeat until the output layer

08

The final prediction is produced

Simple One-Neuron Example

This example shows one forward pass through one neuron.

One-Neuron Forward Pass

Inputs — 2 and 3   Weights — 4 and 5   Bias — 1

Step 1 — 2 × 4 = 8, 3 × 5 = 15

Step 2 — 8 + 15 = 23

Step 3 — 23 + 1 = 24

Step 4 — Apply ReLU: ReLU(24) = 24

Output — 24

Forward Propagation with ReLU

ReLU turns negative values into 0 and keeps positive values unchanged. It is commonly used in hidden layers.

Negative Input

Neuron value: −7

ReLU output: 0

Negative values are turned off.

Positive Input

Neuron value: 12

ReLU output: 12

Positive signals pass forward.

Forward Propagation with Sigmoid

Sigmoid converts a number into a value between 0 and 1. This is useful for binary classification.

Spam Detection Output

Sigmoid output — 0.87

The model estimates an 87% chance that the email is spam.

Threshold — 0.50 → Prediction: Spam

Forward Propagation with Softmax

Softmax converts output scores into probabilities across multiple classes.

Raw Scores

Cat: 4.0

Dog: 2.0

Bird: 1.0

After Softmax

Cat: 0.84

Dog: 0.11

Bird: 0.05

Forward Propagation for Classification

In classification, forward propagation produces class scores or probabilities.

01

Input — Email features

02

Forward Propagation — Moves features through hidden layers

03

Output — Spam probability = 0.91 → Prediction: Spam

Classification models often use sigmoid or softmax in the output layer.

Forward Propagation for Regression

In regression, forward propagation produces a numerical value.

01

Input — House features

02

Forward Propagation — Moves features through hidden layers

03

Output — 450000 → Prediction: $450,000

Regression models often use a linear output layer.

Forward Propagation for Image Recognition

Image recognition models use forward propagation to move pixel data through the network.

01

Input — Image pixels

02

Hidden Layers — Learn edges, shapes, textures, and objects

03

Output — Class probabilities → Prediction: Dog

The model processes numerical pixel values, not images the same way humans see them.

Forward Propagation for Text Models

Text models use forward propagation to process tokens or embeddings and predict language patterns.

Text Example

Input — "The cat sat on the"

Model Output — Probabilities for possible next tokens

Predicted Next Token — "mat"

Large language models generate predictions one token at a time.

Forward Propagation vs Backpropagation

ProcessDirectionPurpose
Forward PropagationInput to outputProduces a prediction
BackpropagationOutput error backwardUpdates weights

Forward Propagation During Inference

Inference means using a trained model to make predictions. During normal inference, the model usually only uses forward propagation.

Example

New email enters trained spam model.

Forward propagation produces — Spam probability = 0.93

Prediction — Spam

No weight updates happen during normal inference.

Forward Propagation During Training

During training, forward propagation is followed by loss calculation and backpropagation.

Training Example

Input — Image of a cat

Forward propagation prediction — Dog

Correct answer — Cat

Loss — High

Backpropagation — Updates weights to reduce future mistakes

Batches and Forward Propagation

Neural networks often process data in batches. A batch is a group of examples processed together.

Example

Batch size — 32 images

Forward propagation — The network produces predictions for all 32 images

Benefit — Batches make training more efficient

Forward Propagation Through Multiple Layers

In a deep network, forward propagation moves through many layers. Each layer transforms the data before passing it onward.

01

Input layer

02

Hidden layer 1

03

Hidden layer 2

04

Hidden layer 3

05

Output layer — final prediction

Matrix Multiplication

Neural networks often use matrix multiplication to make forward propagation efficient.

Layer Calculation Idea

Inputs × Weight matrix + Biases = Layer output

Computers can process many values at once, enabling large batches and deep networks.

This is one reason GPUs are useful for deep learning.

Forward Propagation and Model Parameters

Weights and biases are model parameters. Forward propagation uses these parameters to make predictions.

Forward Propagation

Uses current weights and biases to make predictions.

Backpropagation

Changes weights and biases based on error.

Forward Propagation Before Training

Before training, weights may be random. Forward propagation can still happen, but predictions may be poor.

Before Training

Input — Email features

Prediction — Random or inaccurate

Reason — Weights have not learned useful patterns yet

Forward Propagation After Training

After training, weights contain learned patterns. Forward propagation becomes more useful.

After Training

Input — Email with suspicious links and urgent wording

Prediction — Spam probability = 0.94

Reason — The model learned that these features often appear in spam emails

Forward Propagation and Loss

Forward propagation produces a prediction. The loss function compares that prediction to the correct answer.

Wrong Prediction

Prediction: Dog

Correct Answer: Cat

Loss: High

Correct Prediction

Prediction: Cat

Correct Answer: Cat

Loss: Low

Loss tells the model how wrong the forward pass was.

Forward Propagation and Probabilities

Some output activations create probability-like scores.

Output Activations

Sigmoid — Binary classification. Example: 0.82 = 82% score for positive class.

Softmax — Multi-class classification. Example: Cat 0.70, Dog 0.20, Bird 0.10.

Forward Propagation and Thresholds

For binary classification, the output is often compared to a threshold.

Example

Output — 0.72

Threshold 0.50 — Prediction: Positive

Threshold 0.80 — Same output would predict: Negative

Thresholds affect classification decisions.

Forward Propagation and Errors

Forward propagation can produce wrong predictions. This is normal during training.

Example

Input — Image of a dog

Prediction — Cat

Correct Answer — Dog

The loss function measures the error, then training updates the model.

Why Forward Propagation Is Fast After Training

After training, the model only needs to move data forward to make predictions. It does not need to update weights.

Training

Forward propagation

Loss calculation

Backpropagation

Weight update

Inference

Forward propagation only

Usually faster than training.

Common Mistakes

Common Mistakes
  • Confusing forward propagation with backpropagation
  • Thinking weights change during forward propagation alone
  • Forgetting that activation functions are applied during the forward pass
  • Thinking the input layer makes the final prediction
  • Forgetting that hidden layers transform data
  • Confusing output scores with final class labels
  • Thinking probabilities are always perfectly calibrated
  • Assuming forward propagation only happens during training

Summary

Key Takeaways
  • Forward propagation moves data through a neural network to produce an output.
  • It starts at the input layer and ends at the output layer.
  • Inputs are multiplied by weights.
  • Biases are added to weighted sums.
  • Activation functions transform neuron outputs.
  • Hidden layers learn intermediate patterns.
  • The output layer produces a prediction.
  • Forward propagation is used during training and inference.
  • During training, forward propagation is followed by loss calculation and backpropagation.
  • During inference, forward propagation is usually used by itself.

Practice Prompt

A neuron receives inputs 3 and 4. The weights are 2 and 5. The bias is 1. First calculate the weighted sum, then add the bias. If the neuron uses ReLU, what is the output?

Then explain how this example represents one small step in forward propagation.

Need Help?

Ask the AI if you need help understanding forward propagation, input layers, hidden layers, output layers, weights, biases, activation functions, loss, inference, or the difference between forward propagation and backpropagation.