diff --git a/python/paddle/fluid/dygraph/container.py b/python/paddle/fluid/dygraph/container.py index 0ca32abfbf46aade0f876cc38bc56e8481ec8052..9151e8e04e5a1ea03a2b319fe7910e13d3bbcad8 100644 --- a/python/paddle/fluid/dygraph/container.py +++ b/python/paddle/fluid/dygraph/container.py @@ -201,8 +201,9 @@ class LayerList(Layer): def __init__(self, sublayers=None): super(LayerList, self).__init__() - for idx, layer in enumerate(sublayers): - self.add_sublayer(str(idx), layer) + if sublayers is not None: + for idx, layer in enumerate(sublayers): + self.add_sublayer(str(idx), layer) def __getitem__(self, idx): if isinstance(idx, slice):