You need to sign in or sign up before continuing.
未验证 提交 842fd293 编写于 作者: Z Zhang Ting 提交者: GitHub

remove fluid in default_main_program doc, test=document_fix (#28941)

上级 71c1cd14
......@@ -5400,7 +5400,7 @@ def default_main_program():
This API can be used to get ``default main program`` which store the
descriptions of Ops and tensors.
For example ``z = paddle.fluid.layers.elementwise_add(x, y)`` will create a new ``elementwise_add``
For example ``z = paddle.add(x, y)`` will create a new ``add``
Op and a new ``z`` tensor, and they will be recorded in ``default main program`` .
The ``default main program`` is the default value for ``Program`` parameter in
......@@ -5419,33 +5419,14 @@ def default_main_program():
paddle.enable_static()
# Sample Network:
data = paddle.static.data(name='image', shape=[None, 3, 224, 224], dtype='float32')
label = paddle.static.data(name='label', shape=[None, 1], dtype='int64')
conv1 = paddle.static.nn.conv2d(data, 4, 5, 1, act=None)
bn1 = paddle.static.nn.batch_norm(conv1, act='relu')
pool1 = paddle.fluid.layers.pool2d(bn1, 2, 'max', 2)
conv2 = paddle.static.nn.conv2d(pool1, 16, 5, 1, act=None)
bn2 = paddle.static.nn.batch_norm(conv2, act='relu')
pool2 = paddle.fluid.layers.pool2d(bn2, 2, 'max', 2)
fc1 = paddle.static.nn.fc(x=pool2, size=50, activation='relu')
fc2 = paddle.static.nn.fc(x=fc1, size=102, activation='softmax')
loss = paddle.nn.functional.loss.cross_entropy(input=fc2, label=label)
loss = paddle.mean(loss)
opt = paddle.optimizer.Momentum(
learning_rate=0.1,
momentum=0.9,
weight_decay=paddle.regularizer.L2Decay(1e-4))
opt.minimize(loss)
x = paddle.static.data(name='x', shape=[100, 100], dtype='float32')
y = paddle.static.data(name='x', shape=[100, 100], dtype='float32')
out = paddle.add(x, y)
#print the number of blocks in the program, 1 in this case
print(paddle.static.default_main_program().num_blocks) #[1]
#print the description of variable 'image'
print(paddle.static.default_main_program().num_blocks) # 1
#print the default_main_program
print(paddle.static.default_main_program())
"""
return _main_program_
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册