From 2729c174460dc0a432921d368346e3d725620cbf Mon Sep 17 00:00:00 2001 From: chengduo <30176695+chengduoZH@users.noreply.github.com> Date: Tue, 17 Sep 2019 08:10:23 +0800 Subject: [PATCH] Fix example error of Variable and Operator (#19821) * fix example error test=develop * Remove set_desc test=develop --- python/paddle/fluid/framework.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index bd5f45bba93..0a4ee4ef28b 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -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", -- GitLab