Conv1D
- 类 torch.ao.nn.quantized.functional.conv1d(input, weight, bias, stride=1, padding=0, dilation=1, groups=1, padding_mode='zeros', scale=1.0, zero_point=0, dtype=torch.quint8)[源代码]
-
对该输入进行1D卷积,该输入是由多个输入平面组成的量化1D数据。
详细信息和输出形状请参见
Conv1d
。- 参数
-
-
input - 量化后的输入张量,其形状为$(\text{minibatch} , \text{in\_channels} , iW)$
-
weight – 量化滤波器,其形状为$(\text{out\_channels} , \frac{\text{in\_channels}}{\text{groups}} , iW)$
-
bias – 非量化偏置张量,形状为$(\text{out\_channels})$。其类型必须是torch.float。
-
stride - 卷积核的步幅。可以是单个数值或元组 (sW,)。默认值为 1。
-
padding – 输入两端的隐含填充量。可以是单个数值或元组(padW,)。默认值为0。
-
dilation — 核心元素之间的间隔距离。可以是单个数值或元组 (dW,)。默认值为 1。
-
groups — 将输入分为多个组,其中 $\text{in\_channels}$ 应该能够被组的数量整除。默认值:1
-
padding_mode - 填充模式,当前仅支持量化卷积的 "zeros" 模式。默认值: "zeros"
-
scale - 输出的量化比例因子。默认值:1.0
-
zero_point - 输出量化的零点值。默认值:0
-
dtype – 用于量化的数据类型。默认值:
torch.quint8
-
示例:
>>> from torch.ao.nn.quantized import functional as qF >>> filters = torch.randn(33, 16, 3, dtype=torch.float) >>> inputs = torch.randn(20, 16, 50, dtype=torch.float) >>> bias = torch.randn(33, dtype=torch.float) >>> >>> scale, zero_point = 1.0, 0 >>> dtype_inputs = torch.quint8 >>> dtype_filters = torch.qint8 >>> >>> q_filters = torch.quantize_per_tensor(filters, scale, zero_point, dtype_filters) >>> q_inputs = torch.quantize_per_tensor(inputs, scale, zero_point, dtype_inputs) >>> qF.conv1d(q_inputs, q_filters, bias, padding=1, scale=scale, zero_point=zero_point)