From c4b1faa469a4cfa6d352cfd1ea4cb89273e22a7a Mon Sep 17 00:00:00 2001 From: Li Fuchen Date: Sat, 10 Oct 2020 11:02:47 +0800 Subject: [PATCH] modified sample code of add_position_encoding to use paddle.randn, test=document_fix (#27679) --- python/paddle/fluid/layers/nn.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index dbcd91eedbd..90f7cbe3950 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -13187,12 +13187,10 @@ def add_position_encoding(input, alpha, beta, name=None): Examples: .. code-block:: python - import numpy as np import paddle import paddle.nn.functional as F - tensor = np.random.randn(16, 32, 64) - tensor = paddle.to_tensor(tensor) + tensor = paddle.randn([16, 32, 64]) position_tensor = F.add_position_encoding( input=tensor, alpha=1.0, beta=1.0) -- GitLab