diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 3e7d10f8d1a02126c3d4bec490fcd2f3194123ee..774630e7ef5cdaabfcfc8aac90822b37c47e532c 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -13156,14 +13156,14 @@ def add_position_encoding(input, alpha, beta, name=None): Examples: .. code-block:: python - import paddle.fluid as fluid + import numpy as np + import paddle + import paddle.nn.functional as F - tensor = fluid.data( - name='tensor', - shape=[None, 64, 512], - dtype='float32') - position_tensor = fluid.layers.add_position_encoding( - input=tensor, alpha=1.0, beta=1.0) + tensor = np.random.randn(16, 32, 64) + tensor = paddle.to_tensor(tensor) + position_tensor = F.add_position_encoding( + input=tensor, alpha=1.0, beta=1.0) """ helper = LayerHelper('add_position_encoding', **locals())