Forward
In PyTorch, forward is the module method that defines how inputs are transformed into outputs during a forward pass.
Deep Learning with PyTorch, Second Edition
The standard module-computation entry point in PyTorch, invoked by __call__ and used for the main forward pass.
- How it is used
- Defines the main computation of callable PyTorch modules and custom neural-network components.
- How deep it goes
- Explains method definition, submodule use, invocation mechanics, hooks, and autograd’s implicit backward pass.
- Examples
- Demonstrates nn.Linear invocation and a convolutional Net whose forward method reshapes intermediate tensors.
- What you can do after
- Build custom nn.Module subclasses with explicit data-flow logic and invoke them safely through the module call interface.
Read how Deep Learning with PyTorch, Second Edition explains forward →
Math and Architectures of Deep Learning
The PyTorch module method that defines how inputs are transformed into outputs during a forward pass.
- How it is used
- Defines the computation a PyTorch module performs during a forward pass and supplies outputs for loss calculation.
- How deep it goes
- Explains module structure, Sequential execution, and model invocation, but does not descend into forward's internal autograd mechanics.
- Examples
- Uses demand prediction with linear layers and a sample convolutional neural network with Conv2d layers.
- What you can do after
- Apply it via PyTorch by defining a module's layers and returning their transformed input from forward.
Read how Math and Architectures of Deep Learning explains forward →
Related concepts
- normal distributionproduces · A normal distribution is a continuous probability distribution with a symmetric, bell-shaped density determined by its mean and variance.
- torch.nn.Moduleimplemented by · torch.nn.Module is PyTorch’s base class for neural-network components that encapsulate computation, parameters, and submodules.
- classpart of · A class is a programming-language construct that defines a type’s structure or behavior and provides a basis for creating or representing objects.
- scikit-learnequivalent to · scikit-learn is an open-source Python library providing tools for classical machine learning, including algorithms, preprocessing, model selection, and evaluation.
- functional APIuses · A functional API is an interface that exposes operations as callable functions, with operation inputs supplied through function arguments rather than method-owned state.
- callbackused by · A callback is a function or other callable supplied to software for invocation later in response to a specified event, condition, or point in execution.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

