閾值¶ 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} y={x,value, if x>threshold otherwise 引數 threshold (float) – 作為閾值的值 value (float) – 用於替換的值 inplace (bool) – 可以選擇進行原地操作。預設值: False 形狀 輸入: (∗)(*)(∗), 其中 ∗*∗ 表示任意維數。 輸出: (∗)(*)(∗), 形狀與輸入相同。 示例 >>> m = nn.Threshold(0.1, 20) >>> input = torch.randn(2) >>> output = m(input)