Linear(in_features, out_features, bias=True)¶
Applies a linear transformation to the incoming data:
This module supports TensorFloat32.
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:
Input: where means any number of additional dimensions and
Output: where all but the last dimension are the same shape as the input and .
~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
True, the values are initialized from where
>>> m = nn.Linear(20, 30) >>> input = torch.randn(128, 20) >>> output = m(input) >>> print(output.size()) torch.Size([128, 30])