未验证 提交 937ea24e 编写于 作者: Y yang131313 提交者: GitHub

API doc(en) Bugs fix in 第四期体验评估 (#44749)

* fix docs(en) bugs;test=document_fix

* update paddle.add docs;test=document_fix

* update paddle.where docs;test=document_fix

* for ci;test=document_fix

* Update manipulation.py

* update paddle.where;test=document_fix
Co-authored-by: NLigoml <39876205+Ligoml@users.noreply.github.com>
上级 86763023
......@@ -3082,7 +3082,7 @@ def expand(x, shape, name=None):
Expand the input tensor to a given shape.
Both the number of dimensions of ``x`` and the number of elements in ``shape`` should be less than or equal to 6. The dimension to expand must have a value 1.
Both the number of dimensions of ``x`` and the number of elements in ``shape`` should be less than or equal to 6. And the number of dimensions of ``x`` should be less than the number of elements in ``shape``. The dimension to expand must have a value 1.
Args:
......
......@@ -493,17 +493,55 @@ def _elementwise_op(helper):
def add(x, y, name=None):
"""
Examples:
Elementwise Add Operator.
Add two tensors element-wise
The equation is:
.. code-block:: python
.. math::
import paddle
Out=X+Y
X : a tensor of any dimension.
Y: a tensor whose dimensions must be less than or equal to the dimensions of X.
There are two cases for this operator:
1. The shape of Y is the same with X.
2. The shape of Y is a continuous subsequence of X.
For case 2:
1. Broadcast Y to match the shape of X, where axis is the start dimension index for broadcasting Y onto X.
2. If axis is -1 (default), axis=rank(X)−rank(Y).
3. The trailing dimensions of size 1 for Y will be ignored for the consideration of subsequence, such as shape(Y) = (2, 1) => (2).
For example:
.. code-block:: python
shape(X) = (2, 3, 4, 5), shape(Y) = (,)
shape(X) = (2, 3, 4, 5), shape(Y) = (5,)
shape(X) = (2, 3, 4, 5), shape(Y) = (4, 5), with axis=-1(default) or axis=2
shape(X) = (2, 3, 4, 5), shape(Y) = (3, 4), with axis=1
shape(X) = (2, 3, 4, 5), shape(Y) = (2), with axis=0
shape(X) = (2, 3, 4, 5), shape(Y) = (2, 1), with axis=0
x = paddle.to_tensor([2, 3, 4], 'float64')
y = paddle.to_tensor([1, 5, 2], 'float64')
z = paddle.add(x, y)
print(z) # [3., 8., 6. ]
Args:
x (Tensor) – (Variable), Tensor or LoDTensor of any dimensions. Its dtype should be int32, int64, float32, float64.
y (Tensor) – (Variable), Tensor or LoDTensor of any dimensions. Its dtype should be int32, int64, float32, float64.
with_quant_attr (BOOLEAN) – Whether the operator has attributes used by quantization.
name (string, optional) – Name of the output. Default is None. It’s used to print debug info for developers. Details: :ref:`api_guide_Name`
Returns:
N-dimension tensor. A location into which the result is stored. It’s dimension equals with x
Examples:
.. code-block:: python
import paddle
x = paddle.to_tensor([2, 3, 4], 'float64')
y = paddle.to_tensor([1, 5, 2], 'float64')
z = paddle.add(x, y)
print(z) # [3., 8., 6. ]
"""
if in_dygraph_mode():
......
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......@@ -589,18 +589,18 @@ def where(condition, x=None, y=None, name=None):
Tensor: A Tensor with the same shape as :attr:`condition` and same data type as :attr:`x` and :attr:`y`.
Examples:
.. code-block:: python
:name:where-example
import paddle
x = paddle.to_tensor([0.9383, 0.1983, 3.2, 1.2])
y = paddle.to_tensor([1.0, 1.0, 1.0, 1.0])
out = paddle.where(x>1, x, y)
print(out)
#out: [1.0, 1.0, 3.2, 1.2]
out = paddle.where(x>1)
print(out)
#out: (Tensor(shape=[2, 1], dtype=int64, place=CPUPlace, stop_gradient=True,
......
......@@ -217,6 +217,8 @@ def numel(x, name=None):
Args:
x (Tensor): The input Tensor, it's data type can be bool, float16, float32, float64, int32, int64.
name (str, optional): Name for the operation (optional, default is None).
For more information, please refer to :ref:`api_guide_Name`.
Returns:
Tensor: The number of elements for the input Tensor.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册