評價此頁

Threshold#

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

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

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

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

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

../_images/Threshold.png

示例

>>> m = nn.Threshold(0, 0.5)
>>> input = torch.arange(-3, 3)
>>> output = m(input)
extra_repr()[source]#

返回模組的額外表示。

返回型別

str

forward(input)[source]#

執行前向傳播。

返回型別

張量