Forward propagation is how a network turns an input into a prediction. The data enters at the left and moves through the layers one at a time — each layer does a little matrix math, bends the result, and hands it on — until a single output drops out the end. The tool freezes the weights so you can watch only the flow.
Where you meet it
- Every prediction a trained model makes — image classifier, chatbot, recommender — is one forward pass.
model(x)in PyTorch,model.predict(x)in Keras: that call is the forward pass.- The first half of training: you run forward to get the output, then backward to learn from the error.
What it does
It evaluates the network as a chain of functions. The input vector becomes the first layer's input; that layer's output becomes the next layer's input; repeat. No loops over the data, no learning — just a deterministic walk from input to output. This is also called inference.
A forward pass is just one recipe — multiply, add bias, bend — run over and over until a number falls out.
How it works
Every layer runs the same two-step recipe. First a linear transformation — multiply by a weight matrix and add a bias. Then a nonlinear activation f applied element-wise:
a⁽ˡ⁾ = f(W⁽ˡ⁾ a⁽ˡ⁻¹⁾ + b⁽ˡ⁾)
Here a⁽ˡ⁻¹⁾ is the previous layer's activations (the raw input x for the first layer), W⁽ˡ⁾ the weights, b⁽ˡ⁾ the bias, and f the activation. The tool's net is a small one — 2 → 3 (tanh) → 1 (sigmoid):
z¹ = W¹x + b¹ a¹ = tanh(z¹) # 3 hidden units
z² = W²a¹ + b² ŷ = sigmoid(z²) # one output in (0,1)
That sweep — input, hidden, output — is the entire forward pass. The edges in the tool are the entries of W: cyan for positive weights, pink for negative, thickness for magnitude.
Watch out
- Dimensions must line up. For
W⁽ˡ⁾ a⁽ˡ⁻¹⁾to work,W⁽ˡ⁾has shape(units in layer l) × (units in layer l−1). A shape mismatch is the most common forward-pass error. - No activation = no depth. Without the nonlinear
f, stacking layers collapses into one big linear map — many layers would be no more expressive than a single one. - Forward stores its work. Training keeps the intermediate
z⁽ˡ⁾anda⁽ˡ⁾from the forward pass — backpropagation needs them to compute gradients. Pure inference can throw them away (PyTorch'sno_grad). - The bias
bis added before the activation, not after.
Go deeper
Forward Propagation ist, wie ein Netz aus einer Eingabe eine Vorhersage macht. Die Daten treten links ein und wandern Schicht für Schicht durch — jede Schicht rechnet etwas Matrix-Mathe, biegt das Ergebnis und reicht es weiter — bis am Ende ein einzelner Wert herauskommt. Das Tool fixiert die Gewichte, damit du nur den Fluss beobachtest.
Wo es vorkommt
- Jede Vorhersage eines trainierten Modells — Bildklassifikator, Chatbot, Recommender — ist ein Forward Pass.
model(x)in PyTorch,model.predict(x)in Keras: dieser Aufruf ist der Forward Pass.- Die erste Hälfte des Trainings: vorwärts für die Ausgabe, dann rückwärts, um aus dem Fehler zu lernen.
Was es tut
Es wertet das Netz als Kette von Funktionen aus. Der Eingabevektor wird zur Eingabe der ersten Schicht; deren Ausgabe wird zur Eingabe der nächsten; und so weiter. Keine Schleifen über die Daten, kein Lernen — nur ein deterministischer Weg von Eingabe zu Ausgabe. Man nennt das auch Inferenz.
Ein Forward Pass ist nur ein Rezept — multiplizieren, Bias addieren, biegen — wieder und wieder, bis eine Zahl herausfällt.
Wie es funktioniert
Jede Schicht führt dasselbe zweistufige Rezept aus. Zuerst eine lineare Transformation — mit einer Gewichtsmatrix multiplizieren und einen Bias addieren. Dann eine nichtlineare Aktivierung f, elementweise angewendet:
a⁽ˡ⁾ = f(W⁽ˡ⁾ a⁽ˡ⁻¹⁾ + b⁽ˡ⁾)
Dabei ist a⁽ˡ⁻¹⁾ die Aktivierung der Vorschicht (die rohe Eingabe x bei der ersten Schicht), W⁽ˡ⁾ die Gewichte, b⁽ˡ⁾ der Bias und f die Aktivierung. Das Netz im Tool ist klein — 2 → 3 (tanh) → 1 (sigmoid):
z¹ = W¹x + b¹ a¹ = tanh(z¹) # 3 Hidden Units
z² = W²a¹ + b² ŷ = sigmoid(z²) # eine Ausgabe in (0,1)
Dieser Durchlauf — Eingabe, Hidden, Ausgabe — ist der gesamte Forward Pass. Die Kanten im Tool sind die Einträge von W: cyan für positive Gewichte, pink für negative, Dicke = Betrag.
Worauf achten
- Die Dimensionen müssen passen. Damit
W⁽ˡ⁾ a⁽ˡ⁻¹⁾funktioniert, hatW⁽ˡ⁾die Form(Units in Schicht l) × (Units in Schicht l−1). Eine falsche Form ist der häufigste Forward-Pass-Fehler. - Keine Aktivierung = keine Tiefe. Ohne das nichtlineare
fkollabiert das Stapeln von Schichten zu einer einzigen linearen Abbildung — viele Schichten wären nicht ausdrucksstärker als eine. - Forward merkt sich seine Arbeit. Das Training behält die Zwischenwerte
z⁽ˡ⁾unda⁽ˡ⁾aus dem Forward Pass — die Backpropagation braucht sie für die Gradienten. Reine Inferenz darf sie wegwerfen (PyTorchsno_grad). - Der Bias
bwird vor der Aktivierung addiert, nicht danach.