In the previous section, we briefly mentioned the
nn.Module class as a base parent for all NN building blocks exposed by PyTorch. It's not only a unifying parent for the existing layers—it's much more than that. By subclassing the
nn.Module class, you can create your own building blocks which can be stacked together, reused later, and integrated into the PyTorch framework flawlessly.
At its core,
nn.Module provides quite rich functionality to its children: