Table of Contents
Shortcuts

# 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 y=x A 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)(∗,in_f e a t u res) 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)(o u t_f e a t u res,in_f e a t u res) or (i n_f e a t u r e s)(in\_features)(in_f e a t u res)

  > - Bias: (o u t_f e a t u r e s)(out\_features)(o u t_f e a t u res) or ()()()

  > - Output: (∗,o u t_f e a t u r e s)(*, out\_features)(∗,o u t_f e a t u res) or (∗)(*)(∗), based on the shape of the weight

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.