提交 bd878826 编写于 作者: T typhoonzero

fix rename_var deref

上级 2a3b9ff1
...@@ -747,13 +747,8 @@ class Block(object): ...@@ -747,13 +747,8 @@ class Block(object):
if not self.has_var(name): if not self.has_var(name):
raise ValueError("var %s is not in current" % name) raise ValueError("var %s is not in current" % name)
v = self.var(name) v = self.var(name)
stop_gradient = None
trainable = None
optimize_attr = None
regularizer = None
gradient_clip_attr = None
error_clip = None
if type(v) == Parameter: if type(v) == Parameter:
var_type = "Parameter"
stop_gradient = v.stop_gradient stop_gradient = v.stop_gradient
trainable = v.trainable trainable = v.trainable
optimize_attr = v.optimize_attr optimize_attr = v.optimize_attr
...@@ -761,6 +756,7 @@ class Block(object): ...@@ -761,6 +756,7 @@ class Block(object):
gradient_clip_attr = v.gradient_clip_attr gradient_clip_attr = v.gradient_clip_attr
error_clip = v.error_clip error_clip = v.error_clip
elif type(v) == Variable: elif type(v) == Variable:
var_type = "Variable"
error_clip = v.error_clip error_clip = v.error_clip
stop_gradient = v.stop_gradient stop_gradient = v.stop_gradient
else: else:
...@@ -768,8 +764,7 @@ class Block(object): ...@@ -768,8 +764,7 @@ class Block(object):
self.desc.rename_var(name, new_name) self.desc.rename_var(name, new_name)
d = self.desc.find_var(new_name) d = self.desc.find_var(new_name)
var = None if var_type == "Parameter":
if type(v) == Parameter:
var = Parameter( var = Parameter(
self, self,
d.shape(), d.shape(),
...@@ -781,7 +776,7 @@ class Block(object): ...@@ -781,7 +776,7 @@ class Block(object):
regularizer=regularizer, regularizer=regularizer,
gradient_clip_attr=gradient_clip_attr, gradient_clip_attr=gradient_clip_attr,
error_clip=error_clip) error_clip=error_clip)
elif type(v) == Variable: elif var_type == "Variable":
var = Variable( var = Variable(
self, self,
name=new_name, name=new_name,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册