mindspore/docs/api/api_python/numpy/mindspore.numpy.clip.rst

19 lines
1.2 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.numpy.clip
====================
.. py:function:: mindspore.numpy.clip(x, xmin, xmax, dtype=None)
裁剪(限制)数组的值。给定一个区间,区间外的值会被限制到区间边界。 例如,如果给定区间 :math:`[0,1]` 则小于0的值变为0大于1的值变为1。
参数:
- **x** (Tensor) - 包含需要限制的元素的Tensor。
- **xmin** (Tensor, scalar, None) - 最小值。 如果为None则不在下边界进行限制。 `xmin``xmax` 不可以同时为None。
- **xmax** (Tensor, scalar, None) - 最大值。 如果为None则不在上边界进行限制。 `xmin``xmax` 不可以同时为None。 如果 `xmin``xmax` 是Tensor则这三个Tensor将会广播以匹配它们的shape。
- **dtype** (mindspore.dtype, 可选) - 默认值: ``None`` 。覆盖输出Tensor的dtype。
返回:
Tensor一个包含x的元素的Tensor但小于 `xmin` 的值替换为 `xmin` ,大于 `xmax` 的值替换为 `xmax`
异常:
- **TypeError** - 如果输入的类型不符合上述规定。
- **ValueError** - 如果 `x1``x2` 的shape无法被广播或者 `xmin``xmax` 同时为 `None`