Linear¶
-
class
torch.nn.
Linear
(in_features, out_features, bias=True)[source]¶ Applies a linear transformation to the incoming data:
This module supports TensorFloat32.
- Parameters
in_features – size of each input sample
out_features – size of each output sample
bias – If set to
False
, the layer will not learn an additive bias. Default:True
- Shape:
Input: where means any number of additional dimensions and
Output: where all but the last dimension are the same shape as the input and .
- Variables
~Linear.weight – the learnable weights of the module of shape . The values are initialized from , where
~Linear.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])