nn.combinators.Sequential
- class nn.combinators.Sequential(*args, **kwargs)[source]
Bases:
Build a sequential stack of modules by connecting them end-to-end
Sequentialaccepts any number of modules. The shapes of the modules must be compatible – the output sizesize_outof each module must match the input sizesize_inof the following module.When provided with a list of modules,
Sequentialwill assign module names automatically to each module. If you would like more control over module names, you can provide anOrderedDictto construct the network. In that case, dictionary keys will be used as module names.You can also append additional modules to a network with the
Sequential.append()method. Module names can optionally be provided in this case as well.Examples
Build a
Sequentialstack will be returned aModule, containingmod0,mod1andmod2. When evolving this stack, signals will be passed throughmod0, thenmod1, thenmod2:>>> Sequential(mod0, mod1, mod2)
Index into a
Sequentialstack using Python indexing:>>> mod = Sequential(mod0, mod1, mod2) >>> mod[0] A module with shape (xx, xx)
Build a
Sequentialstack from anOrderedDict:>>> od = OrderedDict([('mod0', mod0), ('mod1', mod1)]) >>> seq = Sequential(od)
Build an empty
Sequential, and useSequential.append():>>> seq = Sequential() >>> seq.append(mod0) >>> seq.append(mod1, 'mod1)
- Parameters:
*mods – Any number of modules to connect. The
size_outattribute of one module must match thesize_inattribute of the following module.- Returns:
A
Modulesubclass object that encapsulates the provided modules
- __init__ = <method-wrapper '__init__' of function object>