評價此頁

閾值#

class torch.nn.Threshold(threshold, value, inplace=False)[來源]#

對輸入 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()[來源]#

返回模組的額外表示。

返回型別

str

forward(input)[來源]#

執行前向傳播。

返回型別

張量