Skip to main content

Sequential

Sequential(*modules) / Sequential(ordered_dict)

Run the given modules in order: Sequential(a, b)(x) == b(a(x)). Modules register under their position ("0", "1", ...), or under the given keys when constructed from an ordered mapping. It is indexable (net[0], net[-1], net[1:3] is a Sequential), sliceable, extendable (append / insert / extend / pop), and concatenates with +.

__init__​

__init__(self, *args: 'Any') -> 'None'

Initialize self. See help(type(self)) for accurate signature.

append​

append(self, module: 'Module') -> "'Sequential'"

append(module) -> Sequential

Add module at the end; returns the container.

extend​

extend(self, sequential: 'Iterable[Module]') -> "'Sequential'"

extend(modules) -> Sequential

Append every module of modules in order; returns the container.

forward​

forward(self, input: 'Any') -> 'Any'

forward(input) -> Any

Feed input through every module in order; each output is the next module's input.

insert​

insert(self, index: 'int', module: 'Module') -> "'Sequential'"

insert(index, module) -> Sequential

Insert module before position index (negative counts from the end); returns the container.

pop​

pop(self, key: 'int | slice') -> 'Module'

pop(key) -> Module

Remove and return the module at key.