From d0406193e3ba7728787f7b666f9e248da76ab974 Mon Sep 17 00:00:00 2001 From: songyouwei Date: Wed, 8 Jan 2020 10:42:22 +0800 Subject: [PATCH] LayerList add sublayer none check (#22135) test=develop --- python/paddle/fluid/dygraph/container.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/dygraph/container.py b/python/paddle/fluid/dygraph/container.py index 0ca32abfbf4..9151e8e04e5 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): -- GitLab