diff --git a/python/paddle/fluid/dygraph/layers.py b/python/paddle/fluid/dygraph/layers.py index b9a43cbbe1afcf32b6319ada384b0d685fdc60e3..b157ce81d82fc7f6d2231fc22a5246b65de31035 100644 --- a/python/paddle/fluid/dygraph/layers.py +++ b/python/paddle/fluid/dygraph/layers.py @@ -959,7 +959,7 @@ class Layer(core.Layer): for prefix, layer in model.named_sublayers(): print(prefix, layer) """ - assert isinstance(sublayer, core.Layer) + assert (isinstance(sublayer, core.Layer) or sublayer == None) self._sub_layers[name] = sublayer return sublayer