当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python PyTorch ReLU6用法及代码示例


本文简要介绍python语言中 torch.nn.quantized.ReLU6 的用法。

用法:

class torch.nn.quantized.ReLU6(inplace=False)

参数

inplace-可以选择就地执行操作。默认值:False

应用逐元素函数:

,其中 是 zero_point,而 是数字 6 的量化表示。

形状:
  • 输入: 其中 * 表示任意数量的附加维度

  • 输出: ,与输入的形状相同

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)

相关用法


注:本文由纯净天空筛选整理自pytorch.org大神的英文原创作品 torch.nn.quantized.ReLU6。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。