diff --git a/python/paddle/nn/layer/container.py b/python/paddle/nn/layer/container.py index ad41535f44ad6a76c9b4cfbfad8644e9a8c85578..48697aa8f509090d44a173a2bc47b1a18184a622 100644 --- a/python/paddle/nn/layer/container.py +++ b/python/paddle/nn/layer/container.py @@ -14,7 +14,7 @@ from collections import OrderedDict from ...fluid.dygraph.layers import Layer -from six.moves import collections_abc +from collections.abc import Iterable, Mapping __all__ = [] @@ -276,12 +276,11 @@ class LayerDict(Layer): """ assert isinstance( - sublayers, collections_abc.Iterable + sublayers, Iterable ), "The type of sublayers is not iterable of key/value pairs, the type of sublayers is " + type( sublayers).__name__ - if isinstance(sublayers, - (OrderedDict, LayerDict, collections_abc.Mapping)): + if isinstance(sublayers, (OrderedDict, LayerDict, Mapping)): for key, layer in sublayers.items(): self.add_sublayer(key, layer) else: