快捷方式

阈值

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 开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源