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

dependabot/pip/python/requests-2.20.0
lujun 6 years ago committed by GitHub
parent 9f85f21880
commit 0f2e7a48c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

Loading…
Cancel
Save