pytorch / 2 / generated / torch.nn.functional.linear.html

torch.nn.functional.linear

torch.nn.functional.linear(input, weight, bias=None) → Tensor

Applies a linear transformation to the incoming data: y = x A T + b y = xA^T + b .

This operation supports 2-D weight with sparse layout

Warning

Sparse support is a beta feature and some layout(s)/dtype/device combinations may not be supported, or may not have autograd support. If you notice missing functionality please open a feature request.

This operator supports TensorFloat32.

Shape:

  • Input: ( , i n _ f e a t u r e s ) (*, in\_features) where * means any number of additional dimensions, including none
  • Weight: ( o u t _ f e a t u r e s , i n _ f e a t u r e s ) (out\_features, in\_features) or ( i n _ f e a t u r e s ) (in\_features)
  • Bias: ( o u t _ f e a t u r e s ) (out\_features) or ( ) ()
  • Output: ( , o u t _ f e a t u r e s ) (*, out\_features) or ( ) (*) , based on the shape of the weight

© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.nn.functional.linear.html