Shortcuts

ReLU6

class torch.ao.nn.quantized.ReLU6(inplace=False)[源代码]

对每个元素应用函数:

ReLU6(x)=min(max(x0,x),q(6))\text{ReLU6}(x) = \min(\max(x_0, x), q(6)), 其中 x0x_0 是零点,并且 q(6)q(6) 是数字6的量化表示。

Parameters

inplace (布尔值) – 可以选择就地执行操作。默认值:False

Shape:
  • 输入:(N,)(N, *) 其中 * 表示任意数量的额外维度

  • 输出: (N,)(N, *), 与输入形状相同

../_images/ReLU6.png

示例:

>>> m = nn.quantized.ReLU6()
>>> input = torch.randn(2)
>>> input = torch.quantize_per_tensor(input, 1.0, 0, dtype=torch.qint32)
>>> output = m(input)
优云智算