未验证 提交 7ca66f1e 编写于 作者: W wanghuancoder 提交者: GitHub

modify Sequential doc, test=develop (#27608)

上级 7698e199
......@@ -34,27 +34,26 @@ class Sequential(Layer):
Examples:
.. code-block:: python
import paddle.fluid as fluid
import paddle
import numpy as np
data = np.random.uniform(-1, 1, [30, 10]).astype('float32')
with fluid.dygraph.guard():
data = fluid.dygraph.to_variable(data)
# create Sequential with iterable Layers
model1 = fluid.dygraph.Sequential(
fluid.Linear(10, 1), fluid.Linear(1, 2)
)
model1[0] # access the first layer
res1 = model1(data) # sequential execution
# create Sequential with name Layer pairs
model2 = fluid.dygraph.Sequential(
('l1', fluid.Linear(10, 2)),
('l2', fluid.Linear(2, 3))
)
model2['l1'] # access l1 layer
model2.add_sublayer('l3', fluid.Linear(3, 3)) # add sublayer
res2 = model2(data) # sequential execution
data = paddle.to_tensor(data)
# create Sequential with iterable Layers
model1 = paddle.nn.Sequential(
paddle.nn.Linear(10, 1), paddle.nn.Linear(1, 2)
)
model1[0] # access the first layer
res1 = model1(data) # sequential execution
# create Sequential with name Layer pairs
model2 = paddle.nn.Sequential(
('l1', paddle.nn.Linear(10, 2)),
('l2', paddle.nn.Linear(2, 3))
)
model2['l1'] # access l1 layer
model2.add_sublayer('l3', paddle.nn.Linear(3, 3)) # add sublayer
res2 = model2(data) # sequential execution
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册