評價此頁

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 的量化表示。

引數

inplace (bool) – 可以選擇是否就地執行操作。預設值:False

形狀
  • 輸入:(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)