From 0f2e7a48c8a8d6ed086baba3ac26f8717a5ad730 Mon Sep 17 00:00:00 2001 From: lujun Date: Wed, 29 May 2019 10:49:05 +0800 Subject: [PATCH] fix:Modify keys in the dictionary of layer.stat_dict in dynamic graph mode, test=develop (#17700) --- python/paddle/fluid/dygraph/layers.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/python/paddle/fluid/dygraph/layers.py b/python/paddle/fluid/dygraph/layers.py index 75d0caa4f74..fe10c8d2644 100644 --- a/python/paddle/fluid/dygraph/layers.py +++ b/python/paddle/fluid/dygraph/layers.py @@ -235,20 +235,19 @@ class Layer(core.Layer): else: 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: destination = collections.OrderedDict() for name, data in self._parameters.items(): if data is not None: - destination[prefix + name] = data + destination[data.name] = data if include_sublayers: for layer_name, layer_item in self._sub_layers.items(): if layer_item is not None: destination_temp = destination.copy() destination_temp.update( - layer_item.state_dict(destination_temp, prefix + - layer_name + ".", + layer_item.state_dict(destination_temp, include_sublayers)) destination = destination_temp return destination -- GitLab