Fix example error of Variable and Operator (#19821)

* fix example error
test=develop

* Remove set_desc
test=develop
expand_as_op_1
chengduo 5 years ago committed by GitHub
parent 8281497030
commit 2729c17446
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -425,7 +425,7 @@ class Variable(object):
.. code-block:: python
import paddle.fluid as fluid
cur_program = Program()
cur_program = fluid.Program()
cur_block = cur_program.current_block()
new_variable = cur_block.create_var(name="X",
shape=[-1, 23, 48],
@ -617,6 +617,17 @@ class Variable(object):
Returns:
str: The debug string.
Examples:
.. code-block:: python
import paddle.fluid as fluid
cur_program = fluid.Program()
cur_block = cur_program.current_block()
new_variable = cur_block.create_var(name="X",
shape=[-1, 23, 48],
dtype='float32')
new_variable.to_string(True)
"""
if in_dygraph_mode():
# TODO(panyx0718): add more dygraph debug info.
@ -642,18 +653,6 @@ class Variable(object):
__repr__ = __str__
def set_desc(self, input):
"""
Set the variable description.
Args:
input(core.VarDesc): The new VarDesc.
Returns:
None
"""
self.desc = input
@property
def stop_gradient(self):
if in_dygraph_mode():
@ -1067,7 +1066,7 @@ class Operator(object):
.. code-block:: python
import paddle.fluid as fluid
cur_program = Program()
cur_program = fluid.Program()
cur_block = cur_program.current_block()
# var1 += var2 + var3
cur_block.append_op(type="sum",

Loading…
Cancel
Save