用法:
class torch.nn.Linear(in_features, out_features, bias=True, device=None, dtype=None)
in_features-每个输入样本的大小
out_features-每个输出样本的大小
bias-如果设置为
False
,该层将不会学习附加偏差。默认值:True
~Linear.weight(torch.Tensor) -形状为 的模块的可学习权重。这些值从 初始化,其中
~Linear.bias-形状为
bias
是True
,则值从 初始化,其中 的模块的可学习偏差。如果
对传入数据应用线性变换:
该模块支持 TensorFloat32。
- 形状:
输入: 其中 表示任意数量的维度,包括 none 和 。
输出: ,其中除了最后一个维度之外的所有维度都与输入和 的形状相同。
例子:
>>> m = nn.Linear(20, 30) >>> input = torch.randn(128, 20) >>> output = m(input) >>> print(output.size()) torch.Size([128, 30])
参数:
变量:
相关用法
- Python torch.nn.LPPool2d用法及代码示例
- Python torch.nn.LPPool1d用法及代码示例
- Python torch.nn.LogSigmoid用法及代码示例
- Python torch.nn.L1Loss用法及代码示例
- Python torch.nn.LeakyReLU用法及代码示例
- Python torch.nn.LogSoftmax用法及代码示例
- Python torch.nn.LocalResponseNorm用法及代码示例
- Python torch.nn.LSTMCell用法及代码示例
- Python torch.nn.LayerNorm用法及代码示例
- Python torch.nn.LSTM用法及代码示例
- Python torch.nn.InstanceNorm3d用法及代码示例
- Python torch.nn.quantized.dynamic.LSTM用法及代码示例
- Python torch.nn.EmbeddingBag用法及代码示例
- Python torch.nn.Module.register_forward_hook用法及代码示例
- Python torch.nn.AvgPool2d用法及代码示例
- Python torch.nn.PixelShuffle用法及代码示例
- Python torch.nn.CELU用法及代码示例
- Python torch.nn.Hardsigmoid用法及代码示例
- Python torch.nn.GLU用法及代码示例
- Python torch.nn.functional.conv1d用法及代码示例
- Python torch.nn.Identity用法及代码示例
- Python torch.nn.Sigmoid用法及代码示例
- Python torch.nn.utils.spectral_norm用法及代码示例
- Python torch.nn.utils.prune.custom_from_mask用法及代码示例
- Python torch.nn.MaxUnpool3d用法及代码示例
注:本文由纯净天空筛选整理自pytorch.org大神的英文原创作品 torch.nn.Linear。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。