liveBook · Manning

Forward pass

As explained in Deep Learning with PyTorch, Second Edition

The stage of model execution that propagates inputs through the network to produce outputs and loss values.

A forward pass feeds input data through a model to produce outputs. Training then compares those outputs with desired values to calculate a loss. section 5.2 section 5.8

A basic training iteration proceeds as follows:

  • Run the forward pass to produce predictions. section 5.8
  • Calculate the loss by comparing predictions with measured or desired outputs. section 5.2
  • Run the backward pass, update parameters with an optimizer, and clear accumulated gradients before the next iteration. section 5.8

The same pass across two GPUs

With two GPUs and a batch of 20, each device can process 10 inputs independently using a replicated model. Each produces its own loss; after backward passes, gradients must be aggregated before updating shared parameters. section 16.3

Figure 16.4 The distributed training steps—forward pass (1), backward pass (2), and update (3) parameters—but missing a critical step since models have different gradients
figure

The diagram connects the forward pass to the backward pass and parameter update, while highlighting gradient synchronization in distributed training. section 16.3

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Explains its place in training and multi-GPU execution, but does not detail layer-level computations.
Examples
Demonstrates noisy-data parameter estimation and independent processing of batch shards across two GPUs.
What it assumes
Assumes input data, desired outputs, and model parameters, while introducing the complete training process from those ingredients.
What you can do after
Apply it via PyTorch as the first step of a training loop before loss calculation and backpropagation.
How it connects
Connects the forward pass to loss functions, backpropagation, optimizers, autograd, and gradient reduction.

Also explained in

Compare how 8 books explain forward pass →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with PyTorch, Second Edition. The section links point to the parts of the book it draws on.