Skip to content

Commit d2bdf1b

Browse files
authored
modify code example, copyfrom: api_name (#4949)
1 parent 500896b commit d2bdf1b

File tree

777 files changed

+951
-14128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

777 files changed

+951
-14128
lines changed

docs/api/paddle/CPUPlace_cn.rst

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,4 @@ CPUPlace
1313
代码示例
1414
::::::::::::
1515

16-
.. code-block:: python
17-
18-
import paddle
19-
cpu_place = paddle.CPUPlace()
20-
21-
16+
COPY-FROM: paddle.CPUPlace

docs/api/paddle/CUDAPinnedPlace_cn.rst

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,4 @@ CUDAPinnedPlace
1414
代码示例
1515
::::::::::::
1616

17-
.. code-block:: python
18-
19-
import paddle
20-
place = paddle.CUDAPinnedPlace()
21-
17+
COPY-FROM: paddle.CUDAPinnedPlace

docs/api/paddle/CUDAPlace_cn.rst

+1-9
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,4 @@ CUDAPlace
2424
代码示例
2525
::::::::::::
2626

27-
.. code-block:: python
28-
29-
import paddle
30-
31-
place = paddle.CUDAPlace(0)
32-
33-
34-
35-
27+
COPY-FROM: paddle.CUDAPlace

docs/api/paddle/ParamAttr_cn.rst

+1-12
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,4 @@ ParamAttr
3535
代码示例
3636
::::::::::::
3737

38-
.. code-block:: python
39-
40-
import paddle
41-
42-
weight_attr = paddle.ParamAttr(name="weight",
43-
learning_rate=0.5,
44-
regularizer=paddle.regularizer.L2Decay(1.0),
45-
trainable=True)
46-
print(weight_attr.name) # "weight"
47-
paddle.nn.Linear(3, 4, weight_attr=weight_attr)
48-
49-
38+
COPY-FROM: paddle.ParamAttr

docs/api/paddle/abs_cn.rst

+1-8
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,4 @@ abs
2525
代码示例
2626
:::::::::
2727

28-
.. code-block:: python
29-
30-
import paddle
31-
32-
x = paddle.to_tensor([-1, -2, -3, -4], dtype='float32')
33-
res = paddle.abs(x)
34-
print(res)
35-
# [1, 2, 3, 4]
28+
COPY-FROM: paddle.abs

docs/api/paddle/acos_cn.rst

+1-8
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,4 @@ arccosine函数。
2525

2626
代码示例
2727
:::::::::
28-
.. code-block:: python
29-
30-
import paddle
31-
32-
x = paddle.to_tensor([-0.8183, 0.4912, -0.6444, 0.0371])
33-
res = paddle.acos(x)
34-
print(res)
35-
# [2.5293, 1.0573, 2.2711, 1.5336]
28+
COPY-FROM: paddle.acos

docs/api/paddle/acosh_cn.rst

+1-8
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,4 @@ Arccosh函数。
2727
代码示例
2828
:::::::::
2929

30-
.. code-block:: python
31-
32-
import paddle
33-
34-
x = paddle.to_tensor([1., 3., 4., 5.])
35-
out = paddle.acosh(x)
36-
print(out)
37-
# [0. , 1.76274729, 2.06343699, 2.29243159]
30+
COPY-FROM: paddle.acosh

docs/api/paddle/add_cn.rst

+1-7
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,4 @@ add
3333
代码示例
3434
:::::::::
3535

36-
.. code-block:: python
37-
38-
import paddle
39-
x = paddle.to_tensor([2, 3, 4], 'float64')
40-
y = paddle.to_tensor([1, 5, 2], 'float64')
41-
z = paddle.add(x, y)
42-
print(z) # [3., 8., 6. ]
36+
COPY-FROM: paddle.add

docs/api/paddle/addmm_cn.rst

+1-13
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,4 @@ addmm
3333
代码示例
3434
::::::::::::
3535

36-
.. code-block:: python
37-
38-
import paddle
39-
40-
x = paddle.ones([2,2])
41-
y = paddle.ones([2,2])
42-
input = paddle.ones([2,2])
43-
44-
out = paddle.addmm( input=input, x=x, y=y, beta=0.5, alpha=5.0 )
45-
46-
print( out.numpy() )
47-
# [[10.5 10.5]
48-
# [10.5 10.5]]
36+
COPY-FROM: paddle.addmm

docs/api/paddle/all_cn.rst

+1-28
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,4 @@ all
2222
代码示例
2323
:::::::::
2424

25-
.. code-block:: python
26-
27-
import paddle
28-
import numpy as np
29-
30-
# x is a bool Tensor variable with following elements:
31-
# [[True, False]
32-
# [True, True]]
33-
x = paddle.assign(np.array([[1, 0], [1, 1]], dtype='int32'))
34-
print(x)
35-
x = paddle.cast(x, 'bool')
36-
37-
# out1 should be [False]
38-
out1 = paddle.all(x) # [False]
39-
print(out1)
40-
41-
# out2 should be [True, False]
42-
out2 = paddle.all(x, axis=0) # [True, False]
43-
print(out2)
44-
45-
# keepdim=False, out3 should be [False, True], out.shape should be (2,)
46-
out3 = paddle.all(x, axis=-1) # [False, True]
47-
print(out3)
48-
49-
# keepdim=True, out4 should be [[False], [True]], out.shape should be (2,1)
50-
out4 = paddle.all(x, axis=1, keepdim=True)
51-
out4 = paddle.cast(out4, 'int32') # [[False], [True]]
52-
print(out4)
25+
COPY-FROM: paddle.all

docs/api/paddle/allclose_cn.rst

+1-30
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,4 @@ allclose
2929
代码示例
3030
::::::::::::
3131

32-
.. code-block:: python
33-
34-
import paddle
35-
import numpy as np
36-
37-
np_x = np.array([10000., 1e-07]).astype("float32")
38-
np_y = np.array([10000.1, 1e-08]).astype("float32")
39-
x = paddle.to_tensor (np_x)
40-
y = paddle.to_tensor (np_y)
41-
result1 = paddle.allclose(x, y, rtol=1e-05, atol=1e-08,
42-
equal_nan=False, name="ignore_nan")
43-
np_result1 = result1.numpy()
44-
# [False]
45-
result2 = paddle.allclose(x, y, rtol=1e-05, atol=1e-08,
46-
equal_nan=True, name="equal_nan")
47-
np_result2 = result2.numpy()
48-
# [False]
49-
50-
np_x = np.array([1.0, float('nan')]).astype("float32")
51-
np_y = np.array([1.0, float('nan')]).astype("float32")
52-
x = paddle.to_tensor (np_x)
53-
y = paddle.to_tensor (np_y)
54-
result1 = paddle.allclose(x, y, rtol=1e-05, atol=1e-08,
55-
equal_nan=False, name="ignore_nan")
56-
np_result1 = result1.numpy()
57-
# [False]
58-
result2 = paddle.allclose(x, y, rtol=1e-05, atol=1e-08,
59-
equal_nan=True, name="equal_nan")
60-
np_result2 = result2.numpy()
61-
# [True]
32+
COPY-FROM: paddle.allclose

docs/api/paddle/any_cn.rst

+1-28
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,4 @@ any
2222
代码示例
2323
:::::::::
2424

25-
.. code-block:: python
26-
27-
import paddle
28-
import numpy as np
29-
30-
# x is a bool Tensor variable with following elements:
31-
# [[True, False]
32-
# [False, False]]
33-
x = paddle.assign(np.array([[1, 0], [1, 1]], dtype='int32'))
34-
print(x)
35-
x = paddle.cast(x, 'bool')
36-
37-
# out1 should be [True]
38-
out1 = paddle.any(x) # [True]
39-
print(out1)
40-
41-
# out2 should be [True, True]
42-
out2 = paddle.any(x, axis=0) # [True, True]
43-
print(out2)
44-
45-
# keepdim=False, out3 should be [True, True], out.shape should be (2,)
46-
out3 = paddle.any(x, axis=-1) # [True, True]
47-
print(out3)
48-
49-
# keepdim=True, result should be [[True], [True]], out.shape should be (2,1)
50-
out4 = paddle.any(x, axis=1, keepdim=True)
51-
out4 = paddle.cast(out4, 'int32') # [[True], [True]]
52-
print(out4)
25+
COPY-FROM: paddle.any

docs/api/paddle/arange_cn.rst

+1-17
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,4 @@ arange
2525
代码示例
2626
::::::::::
2727

28-
.. code-block:: python
29-
30-
import paddle
31-
32-
out1 = paddle.arange(5)
33-
# [0, 1, 2, 3, 4]
34-
35-
out2 = paddle.arange(3, 9, 2.0)
36-
# [3, 5, 7]
37-
38-
# use 4.999 instead of 5.0 to avoid floating point rounding errors
39-
out3 = paddle.arange(4.999, dtype='float32')
40-
# [0., 1., 2., 3., 4.]
41-
42-
start_var = paddle.to_tensor([3])
43-
out4 = paddle.arange(start_var, 7)
44-
# [3, 4, 5, 6]
28+
COPY-FROM: paddle.arange

docs/api/paddle/argsort_cn.rst

+1-35
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,4 @@ Tensor,排序后索引信息(与 ``x`` 维度信息一致),数据类型
2525
代码示例
2626
::::::::::::
2727

28-
.. code-block:: python
29-
30-
import paddle
31-
32-
x = paddle.to_tensor([[[5,8,9,5],
33-
[0,0,1,7],
34-
[6,9,2,4]],
35-
[[5,2,4,2],
36-
[4,7,7,9],
37-
[1,7,0,6]]], dtype='float32')
38-
out1 = paddle.argsort(x=x, axis=-1)
39-
out2 = paddle.argsort(x=x, axis=0)
40-
out3 = paddle.argsort(x=x, axis=1)
41-
print(out1)
42-
#[[[0 3 1 2]
43-
# [0 1 2 3]
44-
# [2 3 0 1]]
45-
# [[1 3 2 0]
46-
# [0 1 2 3]
47-
# [2 0 3 1]]]
48-
print(out2)
49-
#[[[0 1 1 1]
50-
# [0 0 0 0]
51-
# [1 1 1 0]]
52-
# [[1 0 0 0]
53-
# [1 1 1 1]
54-
# [0 0 0 1]]]
55-
print(out3)
56-
#[[[1 1 1 2]
57-
# [0 0 2 0]
58-
# [2 2 0 1]]
59-
# [[2 0 2 0]
60-
# [1 1 0 2]
61-
# [0 2 1 1]]]
62-
28+
COPY-FROM: paddle.argsort

docs/api/paddle/asin_cn.rst

+1-8
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,4 @@ arcsine函数。
2626
代码示例
2727
::::::::::::
2828

29-
.. code-block:: python
30-
31-
import paddle
32-
33-
x = paddle.to_tensor([-0.8183, 0.4912, -0.6444, 0.0371])
34-
res = paddle.asin(x)
35-
print(res)
36-
# [-0.9585, 0.5135, -0.7003, 0.0372]
29+
COPY-FROM: paddle.asin

docs/api/paddle/asinh_cn.rst

+1-8
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,4 @@ Arcsinh函数。
2424
代码示例
2525
:::::::::
2626

27-
.. code-block:: python
28-
29-
import paddle
30-
31-
x = paddle.to_tensor([-0.4, -0.2, 0.1, 0.3])
32-
out = paddle.asinh(x)
33-
print(out)
34-
# [-0.39003533, -0.19869010, 0.09983408, 0.29567307]
27+
COPY-FROM: paddle.asinh

docs/api/paddle/atan2_cn.rst

+1-15
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,4 @@ atan2
3535
代码示例
3636
:::::::::
3737

38-
.. code-block:: python
39-
40-
import paddle
41-
42-
x = paddle.to_tensor([-1, +1, +1, -1]).astype('float32')
43-
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
44-
# [-1, 1, 1, -1])
45-
46-
y = paddle.to_tensor([-1, -1, +1, +1]).astype('float32')
47-
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
48-
# [-1, -1, 1, 1])
49-
50-
out = paddle.atan2(x, y)
51-
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
52-
# [-2.35619450, 2.35619450, 0.78539819, -0.78539819])
38+
COPY-FROM: paddle.atan2

docs/api/paddle/atan_cn.rst

+1-8
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,4 @@ arctangent函数。
2626
代码示例
2727
::::::::::::
2828

29-
.. code-block:: python
30-
31-
import paddle
32-
33-
x = paddle.to_tensor([-0.8183, 0.4912, -0.6444, 0.0371])
34-
res = paddle.atan(x)
35-
print(res)
36-
# [-0.6858, 0.4566, -0.5724, 0.0371]
29+
COPY-FROM: paddle.atan

docs/api/paddle/atanh_cn.rst

+1-8
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,4 @@ Arctanh函数。
2424
代码示例
2525
:::::::::
2626

27-
.. code-block:: python
28-
29-
import paddle
30-
31-
x = paddle.to_tensor([-0.4, -0.2, 0.1, 0.3])
32-
out = paddle.atanh(x)
33-
print(out)
34-
# [-0.42364895, -0.20273256, 0.10033535, 0.30951962]
27+
COPY-FROM: paddle.atanh

0 commit comments

Comments
 (0)