Feedforward network — forward pass
Why "forward"? Because we move from input to output (the prediction direction). Later, backpropagation will move backward to compute gradients. The forward pass is how your trained model actually runs inference in production—it's the airplane's autopilot computing control commands from sensor readings.
The Architecture — What Are We Computing?
Each connection from neuron in layer to neuron in layer has a weight . Each neuron in layer has a bias .
Key insight: A neuron computes a weighted sum of its inputs, adds bias, then applies a nonlinear activation function. Without nonlinearity, stacking layers would collapse to a single linear transformation (useless for complex aerospace dynamics).
The Forward Pass Algorithm — Step by Step Derivation
Starting Point: What Do We Have?
Inputs:
- Input vector (sensor readings)
- Weight matrices where
- Bias vectors where
- Activation functions (often ReLU, sigmoid, tanh, or linear)
Goal: Compute output .
Layer-by-Layer Propagation
Step 1: Initialize
Why? The "activation" of layer0 is just the input data itself. We denote it to make the recursion uniform.
Step 2: For each layer :
(a) Compute pre-activation (weighted sum + bias)*
Why this form?
- Each neuron in layer computes
- In matrix form: has shape , is , so the product is
- This is a linear transformation of the previous layer's output
(b) Apply activation function element-wise
Why activation? Without , the entire network would be: which colapses to , a single affine map. Aerospace systems are nonlinear (stall, shock waves, compressibility)—we need nonlinearity to approximate them.
Step 3: Output
Why stop here? The final layer's activation is the network's prediction. For regression (predicting continuous control surfaces), often is linear (identity). For classification (fault detection: nominal/critical), might be softmax.
Worked Examples — Concrete Calculations
Setup: Predict thrust adjustment from 2 sensors (Mach number, altitude).
- Input: (Mach 0.8, 10k ft)
- Hidden layer: 3 neurons, ReLU activation
- Output layer: 1 neuron, linear activation
Weights and biases (pretrained):
Why these tiny second-column weights? The altitude feature (10000) is huge compared to Mach (0.8). Small weights on the altitude column keep contributions balanced—this is why in practice we normalize inputs before training.
Forward Pass Computation:
Layer 1 (Hidden):
Step 2a: Pre-activation
Why this step? Each neuron aggregates evidence from the input features. Neuron 1 gets strong signal (1.5), neuron 2 weak (0.06), neuron 3 negative (-0.84).
Step 2b: Activation (ReLU: )
Why ReLU here? Negative pre-activation means "this feature combination doesn't fire this neuron." ReLU zeros it out, creating sparse representations (many neurons off). Neuron 3 is "dead" for this input—it detected a pattern that's absent.
Layer 2 (Output):
Step 2a: Pre-activation
Why this step? The output neuron combines the hidden features. Positive weights (1.0, 2.0) amplify neurons 1 and 3; negative weight (-0.5) suppresses neuron 2. Neuron 3 is off, so its connection (2.0) contributes nothing.
Step 2b: Activation (Linear: )
Why linear output? For regression, we want unbounded predictions. The network predicts thrust adjustment of 1.77 N (or whatever units were used in training).
Setup: Fault detection—classify flight state into 3 categories: 0=Nominal, 1=Degraded, 2=Critical.
- Input: (airspeed m/s, throttle fraction, angle-of-attack deg)
- Hidden: 4 neurons, tanh activation
- Output: 3 neurons, softmax activation
Weights:
Forward Pass:
Layer 1 — Pre-activation (computing row by row):
Why check each row? The matrix–vector product is just a dot product per row. Doing them explicitly catches sign errors—a common source of bugs.
Step 2b: Activation (tanh)
Why tanh? Output range centers activations around zero, helping with gradient flow. For aerospace, negative activations can encode "opposite conditions" (e.g., pitch-up vs pitch-down). Notice neuron 4 saturates near .
Layer 2 — Pre-activation ():
Softmax activation:
Sum , so:
Interpretation: The network predicts 97.8% probability of Nominal flight state (class 0), 1.5% Critical, 0.8% Degraded. The argmax is class 0.
Why softmax? It converts arbitrary scores (logits) into a valid probability distribution (sums to 1, all positive). Critical for classification—the pilot needs confidence levels, not raw scores.
Computational Complexity — Why It Matters in Real-Time Systems
Flops per layer: For layer :
- Matrix multiply : multiplications + additions flops
- Bias add: additions
- Activation: function evaluations (ReLU: 1 flop each; tanh: ~10 flops)
Total forward pass: flops, where is activation cost.
Example: For a 10-100-100-5 network (10 inputs, TWO hidden layers of 100, 5 outputs):
- Layer 1: flops
- Layer 2: flops
- Layer 3: flops
- Total: ~23k flops
Why this matters in aerospace: Flight control computers run at high frequency (100-1000 Hz). A 23k-flop network on a 1 GFlop processor takes 23 microseconds—well within a 1 ms control loop. But a 1000-1000-1000-5 network (2M flops) could miss deadlines. Model size is a design constraint for embedded systems.
Common Mistakes — Steel-Manning the Confusion
Wrong approach: Always apply ReLU to output.
Why it feels right: "Every layer needs activation for nonlinearity."
The fix: Output activation depends on the task:
- Regression (continuous values): Linear (identity) or sometimes ReLU if outputs must be non-negative (e.g., thrust ≥ 0)
- Binary classification: Sigmoid (outputs probability in [0,1])
- Multi-class classification: Softmax (outputs probability distribution)
Applying ReLU to regression output would clip negative predictions to zero—catastrophic if you need to predict negative elevator deflection (nose-down command).
Wrong approach: has shape (transposed).
Why it feels right: "Weights connect from previous layer (rows) to current layer (columns)."
The fix: In the standard convention, is so that gives a column vector of size . Each row of contains the incoming weights for one neuron in layer .
Check: If is and should be , then must be for the product to be valid.
Wrong approach: During backpropagation, recompute the forward pass from scratch to get activations.
Why it feels right: "I need values for gradient calculations."
The fix: Cache and during the forward pass. Backprop needs these (especially for computing activation derivatives), and recomputing doubles the cost. In aerospace applications running on resource-constrained hardware, this memory-vs-compute tradeoff is critical.
Implementation tip:
# Store in a dictionary during forward pass
cache = {}
cache[f'z{ell}'] = z
cache[f'a{ell}'] = a
# Access during backprop
z = cache[f'z{ell}']Mnemonic & Recall
Remember: W·A → Z → σ → A for each layer. The cycle repeats times.
Recall Feynman's 12-Year-Old Explanation
Imagine you're playing a video game where you control a plane. The computer needs to decide "should I tilt the nose up or down?" based on what it sees (altitude, speed, etc.).
A feedforward network is like a chain of decision-makers sitting in a row. The first person (input layer) sees the raw numbers from the instruments. They do some simple math (multiply by weights, add bias) and pass their answers to the next person. That person does MORE math on those answers and passes them along. This keeps happening through several people (hidden layers) until the last person (output layer) shouts out the final decision: "Tilt up 5 degrees!"
The "activation function" is like a rule: "If your answer is negative, just say zero instead" (that's ReLU). It makes the math more interesting because without it, all those people in the chain would just be doing one big multiplication, and you'd only need one person.
The "forward pass" means we start at the be
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Dekho, feedforward network ka core idea bahut simple hai — data ek hi direction mein flow karta hai, input se lekar output tak, seedha aage ki taraf. Isiliye ise "forward pass" kehte hain. Socho ki ek airplane ka autopilot hai jo sensors se altitude, velocity, aur angle-of-attack padhta hai, aur phir elevator deflection ya thrust command nikaalta hai. Har layer mein neurons pehle ek weighted sum karte hain (matlab har input ko uske weight se multiply karke jodte hain, phir bias add karte hain), aur uske baad ek nonlinear activation function lagaate hain. Yeh poora process layer-by-layer chalta rehta hai jab tak final output na mil jaaye.
Ab yeh nonlinearity waala part sabse important hai — samjho kyun. Agar hum activation function na lagayein, toh chahe kitni bhi layers stack kar lo, poora network sirf ek single linear transformation ban jaayega, yaani ekdum bekaar. Lekin real aerospace systems toh nonlinear hote hain — stall, shock waves, compressibility, yeh sab complex behaviour hai. Isliye har layer mein ReLU ya sigmoid jaisa nonlinear function daalna zaroori hai, taaki network in complicated dynamics ko approximate kar sake. Yeh chhota sa step hi network ko "powerful" banata hai.
Practically yeh matter isliye karta hai kyunki forward pass hi woh cheez hai jisse tumhara trained model actual mein kaam karta hai — production mein inference isi se hoti hai. Jab tumhara model deploy ho jaata hai, toh yehi algorithm real-time mein predictions deta rehta hai. Aur baad mein jab tum backpropagation seekhoge (jo peeche ki taraf gradients compute karta hai training ke liye), tab yeh forward pass ka foundation kaam aayega. Toh isko achhe se samajh lo — matrix multiplication, bias addition, aur activation — bas yehi teen steps baar-baar repeat hote hain, aur isi se pura neural network chalta hai.