未验证 提交 beec87b9 编写于 作者: L liym27 提交者: GitHub

fix bug in example codes of API case and switch_case. test=develop,test=document_fix (#21477)

上级 7e68bc89
......@@ -1911,6 +1911,7 @@ def case(pred_fn_pairs, default=None, name=None):
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.layers as layers
def fn_1():
return layers.fill_constant(shape=[1, 2], dtype='float32', value=1)
......@@ -1923,7 +1924,7 @@ def case(pred_fn_pairs, default=None, name=None):
main_program = fluid.default_startup_program()
startup_program = fluid.default_main_program()
with program_guard(main_program, startup_program):
with fluid.program_guard(main_program, startup_program):
x = layers.fill_constant(shape=[1], dtype='float32', value=0.3)
y = layers.fill_constant(shape=[1], dtype='float32', value=0.1)
z = layers.fill_constant(shape=[1], dtype='float32', value=0.2)
......@@ -3014,6 +3015,8 @@ def switch_case(branch_index, branch_fns, default=None, name=None):
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.layers as layers
def fn_1():
return layers.fill_constant(shape=[1, 2], dtype='float32', value=1)
......@@ -3025,7 +3028,7 @@ def switch_case(branch_index, branch_fns, default=None, name=None):
main_program = fluid.default_startup_program()
startup_program = fluid.default_main_program()
with program_guard(main_program, startup_program):
with fluid.program_guard(main_program, startup_program):
index_1 = layers.fill_constant(shape=[1], dtype='int32', value=1)
index_2 = layers.fill_constant(shape=[1], dtype='int32', value=2)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册