Linear#
- class torch.ao.nn.quantized.Linear(in_features, out_features, bias_=True, dtype=torch.qint8)[source]#
一个量化的线性模块,输入和输出均为量化张量。我们采用与torch.nn.Linear相同的接口,请参考 https://pytorch.ac.cn/docs/stable/nn.html#torch.nn.Linear 的文档。
与
Linear
类似,属性将在模块创建时被随机初始化,之后会被覆盖。- 变量
示例
>>> m = nn.quantized.Linear(20, 30) >>> input = torch.randn(128, 20) >>> input = torch.quantize_per_tensor(input, 1.0, 0, torch.quint8) >>> output = m(input) >>> print(output.size()) torch.Size([128, 30])