diff --git a/doc/fluid/api_cn/layers_cn/add_position_encoding_cn.rst b/doc/fluid/api_cn/layers_cn/add_position_encoding_cn.rst index abba3377ba359ac496848262f1fe29705ea504b0..b6eda83b8449d53300b75f499d9eb38c9e3cc8d1 100644 --- a/doc/fluid/api_cn/layers_cn/add_position_encoding_cn.rst +++ b/doc/fluid/api_cn/layers_cn/add_position_encoding_cn.rst @@ -40,13 +40,13 @@ add_position_encoding .. 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( + 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)