线性¶
- class torch.ao.nn.quantized.Linear(in_features, out_features, bias_=True, dtype=torch.qint8)[source][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])