Torch.nn.Linear
lastmod 2026-11-10created 2024-05-103 edits
torch.nn.Linear is a PyTorch module that performs a linear transformation (fully connected layer), multiplying the input by a weight matrix and adding a bias. It takes the number of input features in_features and the number of output features out_features as arguments, and the weight and bias are automatically registered as trainable parameters. It is a basic building block that can directly express a linear regression model or form the output layer of multilayer perceptrons and neural networks.