From 9d3b5f0aeeacf40ff10438ca798da2bcfb55f243 Mon Sep 17 00:00:00 2001 From: Albert Zeyer Date: Thu, 28 Oct 2021 16:27:18 +0200 Subject: [PATCH] implement sequential Mentioned in #21 --- nn/container.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nn/container.py b/nn/container.py index b24c7c9c..d752af61 100644 --- a/nn/container.py +++ b/nn/container.py @@ -3,7 +3,7 @@ """ from __future__ import annotations -from .base import Module, ILayerMaker, LayerRef +from .base import Module, ILayerMaker, LayerRef, Layer from typing import Iterable, Iterator, Union, Dict, Callable @@ -81,6 +81,13 @@ def forward(self, inp) -> LayerRef: return inp +def sequential(source: LayerRef, *modules) -> Layer: + """ + Wraps ``Sequential(*modules)(source)`` + """ + return Sequential(*modules)(source) + + def _convert_to_maker(obj: _ModT) -> ILayerMaker: if isinstance(obj, ILayerMaker): return obj