mindspore/docs/api/api_python/ops/mindspore.ops.func_clamp.rst

28 lines
975 B
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.clamp
====================
.. py:function:: mindspore.ops.clamp(input, min=None, max=None)
将输入tensor的所有元素限制在范围 [min, max] 内。
.. math::
out_i= \left\{
\begin{array}{align}
max & \text{ if } input_i\ge max \\
input_i & \text{ if } min \lt input_i \lt max \\
min & \text{ if } input_i \le min \\
\end{array}\right.
.. note::
- `min``max` 不能同时为None
-`min```None`` 时, 无最小值限制
-`max```None`` 时, 无最大值限制.
-`min` 大于 `max`Tensor中所有元素的值会被置为 `max`
参数:
- **input** (Tensor) - 输入tensor。
- **min** (Union(Tensor, float, int),可选) - 指定最小值。默认 ``None``
- **max** (Union(Tensor, float, int),可选) - 指定最大值。默认 ``None``
返回:
Tensor