• 文档 >
  • torch >
  • torch.quantized_batch_norm
快捷键

torch.quantized_batch_norm

torch.quantized_batch_norm(input, weight=None, bias=None, mean, var, eps, output_scale, output_zero_point) Tensor

在一个 4D(NCHW)量化张量上应用批量归一化。

y=xE[x]Var[x]+ϵγ+βy = \frac{x - \mathrm{E}[x]}{\sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta
参数:
  • 输入(张量)- 量化张量

  • 权重(张量)- 对应伽马值的浮点张量,大小为 C

  • 偏置(张量)- 对应贝塔值的浮点张量,大小为 C

  • 均值(张量)- 批标准化中的浮点均值,大小为 C

  • var (Tensor) – 浮点方差张量,大小为 C

  • eps (浮点数) – 为数值稳定性添加到分母的值。

  • output_scale (浮点数) – 输出量化张量缩放

  • output_zero_point (整数) – 输出量化张量零点

返回值:

应用批归一化的量化张量。

返回类型:

张量

示例:

>>> qx = torch.quantize_per_tensor(torch.rand(2, 2, 2, 2), 1.5, 3, torch.quint8)
>>> torch.quantized_batch_norm(qx, torch.ones(2), torch.zeros(2), torch.rand(2), torch.rand(2), 0.00001, 0.2, 2)
tensor([[[[-0.2000, -0.2000],
      [ 1.6000, -0.2000]],

     [[-0.4000, -0.4000],
      [-0.4000,  0.6000]]],


    [[[-0.2000, -0.2000],
      [-0.2000, -0.2000]],

     [[ 0.6000, -0.4000],
      [ 0.6000, -0.4000]]]], size=(2, 2, 2, 2), dtype=torch.quint8,
   quantization_scheme=torch.per_tensor_affine, scale=0.2, zero_point=2)

© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,并使用 Read the Docs 提供的主题。

文档

PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源