diff --git a/python/paddle/fluid/dygraph/container.py b/python/paddle/fluid/dygraph/container.py index e80bc1245f9ce44de9cb048373c1f073590a2edc..345b71d8999ebd6c6a4e587a1f0c4f803c32c929 100644 --- a/python/paddle/fluid/dygraph/container.py +++ b/python/paddle/fluid/dygraph/container.py @@ -69,6 +69,8 @@ class Sequential(Layer): def __getitem__(self, name): if isinstance(name, slice): return self.__class__(*(list(self._sub_layers.values())[name])) + elif isinstance(name, str): + return self._sub_layers[name] else: if name >= len(self._sub_layers): raise IndexError('index {} is out of range'.format(name))