Skip to content

Commit

Permalink
modify example code in docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
OccupyMars2025 committed Oct 17, 2022
1 parent 8c7f144 commit 518038c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions python/paddle/incubate/sparse/unary.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,19 +678,17 @@ def reshape(x, shape, name=None):
.. code-block:: python
import paddle
import numpy as np
x_shape = [6, 2, 3]
new_shape = [1, 0, 2, -1, 3]
format = "coo"
mask = np.random.randint(0, 2, x_shape)
np_x = np.random.randint(-100, 100, x_shape) * mask
dense_x = paddle.randint(-100, 100, x_shape) * paddle.randint(0, 2, x_shape)
if format == "coo":
sp_x = paddle.to_tensor(np_x).to_sparse_coo(len(x_shape))
sp_x = dense_x.to_sparse_coo(len(x_shape))
else:
sp_x = paddle.to_tensor(np_x).to_sparse_csr()
sp_x = dense_x.to_sparse_csr()
sp_out = paddle.incubate.sparse.reshape(sp_x, new_shape)
print(sp_out)
Expand Down

0 comments on commit 518038c

Please sign in to comment.