Linear¶
- class torch.nn.Linear(in_features, out_features, bias=True, device=None, dtype=None)[source]¶
Applies a linear transformation to the incoming data: .
This module supports TensorFloat32.
On certain ROCm devices, when using float16 inputs this module will use different precision for backward.
- Parameters
- Shape:
Input: where means any number of dimensions including none and .
Output: where all but the last dimension are the same shape as the input and .
- Variables
weight (torch.Tensor) – the learnable weights of the module of shape . The values are initialized from , where
bias – the learnable bias of the module of shape . If
bias
isTrue
, the values are initialized from where
Examples:
>>> m = nn.Linear(20, 30) >>> input = torch.randn(128, 20) >>> output = m(input) >>> print(output.size()) torch.Size([128, 30])