阈值¶ 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)