Python — From Basics to Advanced · PyTorch — Tensors, Autograd, and a Simple MLP
nn.Module — Defining a Model
PyTorch — Tensors, Autograd, and a Simple MLP
Introduction
nn.Module is the base class for all models. You subclass it, define layers in __init__, and the forward pass in forward(). __call__ delegates to forward plus hooks. Parameter discovery is automatic.