nn.combinators.Residual

class nn.combinators.Residual(*args, **kwargs)[source]

Bases:

Build a residual block over a sequential stack of modules

Residual accepts any number of modules. The shapes of the modules must be compatible – the output size size_out of each module must match the input size size_in of the following module.

Examples

Build a Residual stack will be returned a Module, containing mod0, mod1 and mod2. When evolving this stack, signals will be passed through mod0, then mod1, then mod2:

>>> Residual(mod0, mod1, mod2)

Index into a Residual stack using Python indexing:

>>> mod = Residual(mod0, mod1, mod2)
>>> mod[0]
A module with shape (xx, xx)
Parameters:

*mods – Any number of modules to connect. The size_out attribute of one module must match the size_in attribute of the following module.

Returns:

A Module subclass object that encapsulates the provided modules

__init__ = <method-wrapper '__init__' of function object>