mindspore.mint.nn.functional.threshold_

查看源文件
mindspore.mint.nn.functional.threshold_(input, threshold, value)[源代码]

通过逐元素计算 Threshold 激活函数,原地更新 input Tensor。

Threshold定义为:

\[\begin{split}y = \begin{cases} x, &\text{ if } x > \text{threshold} \\ \text{value}, &\text{ otherwise } \end{cases}\end{split}\]
参数:
  • input (Tensor) - 输入Tensor。

  • threshold (Union[int, float]) - 阈值。

  • value (Union[int, float]) - 小于阈值时的填充值。

返回:

Tensor,数据类型和shape与 input 相同。

异常:
  • TypeError - input 不是Tensor。

  • TypeError - threshold 不是浮点数或整数。

  • TypeError - value 不是浮点数或整数。

支持平台:

Ascend

样例:

>>> import mindspore
>>> from mindspore import Tensor, mint
>>> inputs = mindspore.Tensor([0.0, 2, 3], mindspore.float32)
>>> outputs = mint.nn.functional.threshold_(inputs, 1, 100)
>>> print(outputs)
[100.   2.   3.]