Skip to content

Commit 2729c17

Browse files
authored
Fix example error of Variable and Operator (#19821)
* fix example error test=develop * Remove set_desc test=develop
1 parent 8281497 commit 2729c17

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

python/paddle/fluid/framework.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class Variable(object):
425425
.. code-block:: python
426426
427427
import paddle.fluid as fluid
428-
cur_program = Program()
428+
cur_program = fluid.Program()
429429
cur_block = cur_program.current_block()
430430
new_variable = cur_block.create_var(name="X",
431431
shape=[-1, 23, 48],
@@ -617,6 +617,17 @@ def to_string(self, throw_on_error, with_details=False):
617617
618618
Returns:
619619
str: The debug string.
620+
621+
Examples:
622+
.. code-block:: python
623+
624+
import paddle.fluid as fluid
625+
cur_program = fluid.Program()
626+
cur_block = cur_program.current_block()
627+
new_variable = cur_block.create_var(name="X",
628+
shape=[-1, 23, 48],
629+
dtype='float32')
630+
new_variable.to_string(True)
620631
"""
621632
if in_dygraph_mode():
622633
# TODO(panyx0718): add more dygraph debug info.
@@ -642,18 +653,6 @@ def to_string(self, throw_on_error, with_details=False):
642653

643654
__repr__ = __str__
644655

645-
def set_desc(self, input):
646-
"""
647-
Set the variable description.
648-
649-
Args:
650-
input(core.VarDesc): The new VarDesc.
651-
652-
Returns:
653-
None
654-
"""
655-
self.desc = input
656-
657656
@property
658657
def stop_gradient(self):
659658
if in_dygraph_mode():
@@ -1067,7 +1066,7 @@ class Operator(object):
10671066
.. code-block:: python
10681067
10691068
import paddle.fluid as fluid
1070-
cur_program = Program()
1069+
cur_program = fluid.Program()
10711070
cur_block = cur_program.current_block()
10721071
# var1 += var2 + var3
10731072
cur_block.append_op(type="sum",

0 commit comments

Comments
 (0)