Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions docs/api/paddle/multiplex_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,4 @@ Tensor, 进行Multiplex运算后的输出Tensor。
代码示例
::::::::::::

.. code-block:: python

import paddle
import numpy as np
img1 = np.array([[1, 2], [3, 4]]).astype(np.float32)
img2 = np.array([[5, 6], [7, 8]]).astype(np.float32)
inputs = [paddle.to_tensor(img1), paddle.to_tensor(img2)]
index = paddle.to_tensor(np.array([[1], [0]]).astype(np.int32))
res = paddle.multiplex(inputs, index)
print(res)
# [[5. , 6.],
# [3. , 4.]]
COPY-FROM: paddle.multiplex:code-example1
13 changes: 1 addition & 12 deletions docs/api/paddle/put_along_axis_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,4 @@ put_along_axis
代码示例
:::::::::

.. code-block:: python

import paddle

x = paddle.to_tensor([[10, 30, 20], [60, 40, 50]])
index = paddle.to_tensor([[0]])
value = 99
axis = 0
result = paddle.put_along_axis(x, index, value, axis)
print(result)
# [[99, 99, 99],
# [60, 40, 50]]
COPY-FROM: paddle.put_along_axis:code-example1
25 changes: 1 addition & 24 deletions docs/api/paddle/reshape_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,7 @@ reshape
代码示例
::::::::::::

.. code-block:: python

import numpy as np
import paddle

x = paddle.rand([2, 4, 6], dtype="float32")
positive_four = paddle.full([1], 4, "int32")

out = paddle.reshape(x, [-1, 0, 3, 2])
print(out)
# the shape is [2,4,3,2].

out = paddle.reshape(x, shape=[positive_four, 12])
print(out)
# the shape of out_2 is [4, 12].

shape_tensor = paddle.to_tensor(np.array([8, 6]).astype("int32"))
out = paddle.reshape(x, shape=shape_tensor)
print(out)
# the shape is [8, 6].
# 在动态图模式下,输出out与输入x共享数据
x[0, 0, 0] = 10.
print(out[0, 0])
# the value is [10.]
COPY-FROM: paddle.reshape:code-example1



Expand Down
11 changes: 1 addition & 10 deletions docs/api/paddle/take_along_axis_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,4 @@ take_along_axis
代码示例
:::::::::

.. code-block:: python

import paddle

x = paddle.to_tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
index = paddle.to_tensor([[0]])
axis = 0
result = paddle.take_along_axis(x, index, axis)
print(result)
# [[1, 2, 3]]
COPY-FROM: paddle.take_along_axis:code-example1