未验证 提交 73e51a17 编写于 作者: L Leo Chen 提交者: GitHub

add stop_gradient property and remove reduce redundant information (#29185)

* add stop_gradient property and remove reduce redundant information

* refine code
上级 64f29fbb
......@@ -1313,12 +1313,15 @@ class Variable(object):
dtype='float32')
print(new_variable._to_readable_code())
"""
# VarType.LOD_TENSOR -> LOD_TENSOR
type_str = str(self.type).split('.')[1]
if self.type == core.VarDesc.VarType.SELECTED_ROWS or self.type == core.VarDesc.VarType.LOD_TENSOR:
var_str = "{name} : paddle.{type}.shape{shape}.astype({dtype})".\
format(i="{", e="}", name=self.name, type=self.type, shape=self.shape, dtype=self.dtype)
dtype_str = str(self.dtype).split('.')[1]
var_str = "{name} : {type}.shape{shape}.dtype({dtype}).stop_gradient({stop_gradient})".\
format(name=self.name, type=type_str, shape=self.shape, dtype=dtype_str, stop_gradient=self.stop_gradient)
else:
var_str = "{name} : paddle.{type})".\
format(i="{", e="}", name=self.name, type=self.type)
var_str = "{name} : {type})".\
format(name=self.name, type=type_str)
if type(self) == Parameter:
if self.trainable:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册