From 73c7d7690ddce854d09c0bfff8654e21ff69a8b2 Mon Sep 17 00:00:00 2001 From: Ligoml Date: Wed, 7 Sep 2022 04:06:38 +0000 Subject: [PATCH] fix_np_issue --- python/paddle/tensor/linalg.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/python/paddle/tensor/linalg.py b/python/paddle/tensor/linalg.py index 700c6c340dc..20ab6c1310c 100644 --- a/python/paddle/tensor/linalg.py +++ b/python/paddle/tensor/linalg.py @@ -634,10 +634,9 @@ def dist(x, y, p=2, name=None): .. code-block:: python import paddle - import numpy as np - x = paddle.to_tensor(np.array([[3, 3],[3, 3]]), "float32") - y = paddle.to_tensor(np.array([[3, 3],[3, 1]]), "float32") + x = paddle.to_tensor([[3, 3],[3, 3]], "float32") + y = paddle.to_tensor([[3, 3],[3, 1]], "float32") out = paddle.dist(x, y, 0) print(out) # out = [1.] @@ -1046,12 +1045,9 @@ def dot(x, y, name=None): .. code-block:: python import paddle - import numpy as np - x_data = np.random.uniform(0.1, 1, [10]).astype(np.float32) - y_data = np.random.uniform(1, 3, [10]).astype(np.float32) - x = paddle.to_tensor(x_data) - y = paddle.to_tensor(y_data) + x=paddle.uniform(shape=[10],dtype='float32', min=0.1, max=1, seed=10, name=None) + y=paddle.uniform(shape=[10],dtype='float32', min=1, max=3, seed=10, name=None) z = paddle.dot(x, y) print(z) -- GitLab