diff --git a/python/paddle/fluid/dygraph/layers.py b/python/paddle/fluid/dygraph/layers.py index 75d0caa4f7441cb2da9f9aa8a6367e9f90aa3fb7..fe10c8d2644fd49bf666a46d76b3e4bfb6ef0c8e 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