评价此页

Linear#

class torch.ao.nn.quantized.dynamic.Linear(in_features, out_features, bias_=True, dtype=torch.qint8)[源]#

一个动态量化线性模块,其输入和输出为浮点张量。我们采用与 torch.nn.Linear 相同的接口,请参阅 https://pytorch.ac.cn/docs/stable/nn.html#torch.nn.Linear 的文档。

torch.nn.Linear 类似,属性将在模块创建时随机初始化,稍后将被覆盖。

变量
  • weight (Tensor) – 模块的不可学习的量化权重,形状为 (out_features,in_features)(\text{out\_features}, \text{in\_features})

  • bias (Tensor) – 模块的不可学习的浮点偏置,形状为 (out_features)(\text{out\_features})。如果 biasTrue,则值初始化为零。

示例

>>> m = nn.quantized.dynamic.Linear(20, 30)
>>> input = torch.randn(128, 20)
>>> output = m(input)
>>> print(output.size())
torch.Size([128, 30])
classmethod from_float(mod, use_precomputed_fake_quant=False)[源]#

从浮点模块或 qparams_dict 创建动态量化模块。

参数

mod (Module) – 一个浮点模块,由 torch.ao.quantization 工具生成或用户提供

classmethod from_reference(ref_qlinear)[源]#

从参考量化模块创建(fbgemm/qnnpack)动态量化模块 :param ref_qlinear: 一个参考量化模块,由 :type ref_qlinear: Module :param torch.ao.quantization 函数生成或用户提供。