giagrad.nn.Module.add_module#

Module.add_module(module, name=None)[source]#

Adds a child module to the current module.

The module can be accessed as an attribute using the given name.

Parameters:
  • module (Module) – Child module to be added to the current module.

  • name (str, optional) – Name of the child module. If no name is supplied its name becomes module%i where %i is the number of submodules already defined in self.

Examples

>>> mod = nn.Sequential()
>>> mod.add_module(nn.Linear(10, 10))
>>> mod.module0
Layer(in=10, out=10, bias=True)