Skip to content

Commit c61ac9e

Browse files
Update search.py
1 parent 2483b82 commit c61ac9e

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

python/paddle/tensor/search.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,13 @@ def where(condition, x=None, y=None, name=None):
567567
\begin{cases}
568568
x_i, & \text{if} \ condition_i \ \text{is} \ True \\
569569
y_i, & \text{if} \ condition_i \ \text{is} \ False \\
570-
\end{cases}
570+
\end{cases}.
571571
572572
Notes:
573-
``paddle.where(condition)`` is identical to ``paddle.nonzero(condition, as_tuple=True)``.
573+
``numpy.where(condition)`` is identical to ``paddle.nonzero(condition, as_tuple=True)``, please refer to :ref:`api_tensor_search_nonzero`.
574574
575575
Args:
576-
condition (Tensor): The condition to choose x or y. When True(nonzero), yield x, otherwise yield y.
576+
condition (Tensor): The condition to choose x or y. When True (nonzero), yield x, otherwise yield y.
577577
x (Tensor|scalar, optional): A Tensor or scalar to choose when the condition is True with data type of float32, float64, int32 or int64. Either both or neither of x and y should be given.
578578
y (Tensor|scalar, optional): A Tensor or scalar to choose when the condition is False with data type of float32, float64, int32 or int64. Either both or neither of x and y should be given.
579579
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
@@ -583,22 +583,22 @@ def where(condition, x=None, y=None, name=None):
583583
584584
Examples:
585585
.. code-block:: python
586-
:name:where-example
586+
:name:where-example
587587
588-
import paddle
588+
import paddle
589589
590-
x = paddle.to_tensor([0.9383, 0.1983, 3.2, 1.2])
591-
y = paddle.to_tensor([1.0, 1.0, 1.0, 1.0])
592-
out = paddle.where(x>1, x, y)
590+
x = paddle.to_tensor([0.9383, 0.1983, 3.2, 1.2])
591+
y = paddle.to_tensor([1.0, 1.0, 1.0, 1.0])
592+
out = paddle.where(x>1, x, y)
593593
594-
print(out)
595-
#out: [1.0, 1.0, 3.2, 1.2]
594+
print(out)
595+
#out: [1.0, 1.0, 3.2, 1.2]
596596
597-
out = paddle.where(x>1)
598-
print(out)
599-
#out: (Tensor(shape=[2, 1], dtype=int64, place=CPUPlace, stop_gradient=True,
600-
# [[2],
601-
# [3]]),)
597+
out = paddle.where(x>1)
598+
print(out)
599+
#out: (Tensor(shape=[2, 1], dtype=int64, place=CPUPlace, stop_gradient=True,
600+
# [[2],
601+
# [3]]),)
602602
"""
603603
if np.isscalar(x):
604604
x = paddle.full([1], x, np.array([x]).dtype.name)

0 commit comments

Comments
 (0)