Conv2d

torch.ao.nn.quantized.Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', device=None, dtype=None)[源代码]

对该输入信号进行二维卷积操作,该信号由多个量化输入平面组成。

关于输入参数、超参数和实现的详情,请参阅Conv2d

注意

仅支持zeros作为padding_mode参数的值。

注意

仅支持torch.quint8作为输入数据类型的。

变量
  • weight (Tensor) – 由可学习的权重参数派生而来的打包张量。

  • scale (张量) – 控制输出尺度的标量值

  • zero_point (Tensor) – 表示输出零点的标量值

参见 Conv2d 以获取其他属性。

示例:

>>> # With square kernels and equal stride
>>> m = nn.quantized.Conv2d(16, 33, 3, stride=2)
>>> # non-square kernels and unequal stride and with padding
>>> m = nn.quantized.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2))
>>> # non-square kernels and unequal stride and with padding and dilation
>>> m = nn.quantized.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2), dilation=(3, 1))
>>> input = torch.randn(20, 16, 50, 100)
>>> # quantize input to quint8
>>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8)
>>> output = m(q_input)
classmethodfrom_float(mod, use_precomputed_fake_quant=False)[源代码]

根据浮点模块或 qparams_dict 创建量化模块。

参数

mod (Module) – 一个浮点模块,该模块可以通过 torch.ao.quantization 工具生成,或者由用户自行提供。

本页目录