當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。