快捷方式

閾值

class torch.nn.Threshold(threshold, value, inplace=False)[source][source]

對輸入張量的每個元素進行閾值處理。

Threshold 定義為

y={x, if x>thresholdvalue, otherwise y = \begin{cases} x, &\text{ if } x > \text{threshold} \\ \text{value}, &\text{ otherwise } \end{cases}
引數
  • threshold (float) – 作為閾值的值

  • value (float) – 用於替換的值

  • inplace (bool) – 可以選擇進行原地操作。預設值: False

形狀
  • 輸入: ()(*), 其中 * 表示任意維數。

  • 輸出: ()(*), 形狀與輸入相同。

示例

>>> m = nn.Threshold(0.1, 20)
>>> input = torch.randn(2)
>>> output = m(input)

文件

訪問全面的 PyTorch 開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源