Rate this Page

Linear#

classtorch.nn.Linear(in_features,out_features,bias=True,device=None,dtype=None)[source]#

Applies an affine linear transformation to the incoming data:y=xAT+by = xA^T + b.

This module supportsTensorFloat32.

On certain ROCm devices, when using float16 inputs this module will usedifferent precision for backward.

Parameters
  • in_features (int) – size of each input sample

  • out_features (int) – size of each output sample

  • bias (bool) – If set toFalse, the layer will not learn an additive bias.Default:True

Shape:
Variables

Examples:

>>>m=nn.Linear(20,30)>>>input=torch.randn(128,20)>>>output=m(input)>>>print(output.size())torch.Size([128, 30])
extra_repr()[source]#

Return the extra representation of the module.

Return type

str

forward(input)[source]#

Runs the forward pass.

Return type

Tensor

reset_parameters()[source]#

Resets parameters based on their initialization used in__init__.