提交 9484567b 编写于 作者: L lfchener

modified sample code of add_position_encoding to 2.0, test=document_fix

上级 36ed83d2
......@@ -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())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册