未验证 提交 0f2e7a48 编写于 作者: L lujun 提交者: GitHub

fix:Modify keys in the dictionary of layer.stat_dict in dynamic graph mode, test=develop (#17700)

上级 9f85f218
...@@ -235,20 +235,19 @@ class Layer(core.Layer): ...@@ -235,20 +235,19 @@ class Layer(core.Layer):
else: else:
object.__delattr__(self, name) object.__delattr__(self, name)
def state_dict(self, destination=None, prefix='', include_sublayers=True): def state_dict(self, destination=None, include_sublayers=True):
if destination is None: if destination is None:
destination = collections.OrderedDict() destination = collections.OrderedDict()
for name, data in self._parameters.items(): for name, data in self._parameters.items():
if data is not None: if data is not None:
destination[prefix + name] = data destination[data.name] = data
if include_sublayers: if include_sublayers:
for layer_name, layer_item in self._sub_layers.items(): for layer_name, layer_item in self._sub_layers.items():
if layer_item is not None: if layer_item is not None:
destination_temp = destination.copy() destination_temp = destination.copy()
destination_temp.update( destination_temp.update(
layer_item.state_dict(destination_temp, prefix + layer_item.state_dict(destination_temp,
layer_name + ".",
include_sublayers)) include_sublayers))
destination = destination_temp destination = destination_temp
return destination return destination
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册