mindspore/docs/api/api_python/ops/mindspore.ops.func_hardtanh...

29 lines
1.0 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.hardtanh
======================
.. py:function:: mindspore.ops.hardtanh(x, min_val=-1.0, max_val=1.0)
逐元素元素计算hardtanh激活函数。hardtanh函数定义为
.. math::
\text{hardtanh}(x) = \begin{cases}
1, & \text{ if } x > 1; \\
-1, & \text{ if } x < -1; \\
x, & \text{ otherwise. }
\end{cases}
线性区域范围 :math:`[-1, 1]` 可以使用 `min_val``max_val` 进行调整。
参数:
- **x** (Tensor) - 输入Tensor。
- **min_val** (Union[int, float]) - 线性区域范围的最小值。默认值:-1.0。
- **max_val** (Union[int, float]) - 线性区域范围的最大值。默认值1.0。
返回:
Tensor数据类型和shape与 `x` 的相同。
异常:
- **TypeError** - `x` 不是Tensor。
- **TypeError** - `min_val` 的数据类型既不是int也不是float。
- **TypeError** - `max_val` 的数据类型既不是int也不是float。