torch.nn — PyTorch 2.8 documentation
torch.nn# Created On: Dec 23, 2016 | Last Updated On: Nov 06, 2024 These are the basic building blocks for graphs: torch.nn Containers Convolution Layers Pooling layers Padding Layers Non-linear Activations (weighted sum, nonlinearity) Non-linear Activations (other) Normalization Layers Recurrent Layers Transformer Layers Linear Layers Dropout Layers Sparse Layers Distance Functions Loss Functions Vision Layers Shuffle Layers DataParallel Layers (multi-GPU, distributed) Utilities Quantized Functions Lazy Modules Initialization Aliases Buffer A kind of Tensor that should not be considered a model parameter. Parameter A kind of Tensor that is to be considered a module parameter. UninitializedParameter A parameter that is not initialized. UninitializedBuffer A buffer that is not initialized. Containers# Module Base class for all neural network modules. Sequential A sequential container. ModuleList Holds submodules in a list. ModuleDict Holds submodules in a dictionary. ParameterList Holds parameters in a list. ParameterDict Holds parameters in a dictionary. Global Hooks For Module register_module_forward_pre_hook Register a forward pre-hook common to all modules. register_module_forward_hook Register a global forward hook for all the modules. register_module_backward_hook Register a backward hook common to all the modules. register_module_full_backward_pre_hook Register a backward pre-hook common to all the modules. register_module_full_backward_hook Register a backward hook common to all the modules. register_module_buffer_registration_hook Register a buffer registration hook common to all modules. register_module_module_registration_hook Register a module registration hook common to all modules. register_module_parameter_registration_hook Register a parameter registration hook common to all modules. Convolution Layers# nn.Conv1d Applies a 1D convolution over an input signal composed of several input planes. nn.Conv2d Applies a 2D convolution over an input signal composed of several input planes. nn.Conv3d Applies a 3D convolution over an input signal composed of several input planes. nn.ConvTranspose1d Applies a 1D transposed convolution operator over an input image composed of several input planes. nn.ConvTranspose2d Applies a 2D transposed convolution operator over an input image composed of several input planes. nn.ConvTranspose3d Applies a 3D transposed convolution operator over an input image composed of several input planes. nn.LazyConv1d A torch.nn.Conv1d module with lazy initialization of the in_channels argument. nn.LazyConv2d A torch.nn.Conv2d module with lazy initialization of the in_channels argument. nn.LazyConv3d A torch.nn.Conv3d module with lazy initialization of the in_channels argument. nn.LazyConvTranspose1d A torch.nn.ConvTranspose1d module with lazy initialization of the in_channels argument. nn.LazyConvTranspose2d A torch.nn.ConvTranspose2d module with lazy initialization of the in_channels argument. nn.LazyConvTranspose3d…