IndependentCellTrainer

class IndependentCellTrainer(**kwargs)[source]

Bases: CellTrainer, ABC

Trainer for update methods without inter-cell dependencies.

Important

The Layer object “owns” the Cell objects but not the Monitor objects.

If applying a function to Module objects, e.g. via calling to() on the CellTrainer, ~inferno.neural.Cell objects will not be altered but ~inferno.observe.Monitor and auxiliary state objects will be.

Likewise, calling to() on the Layer will alter ~inferno.neural.Cell objects but not ~inferno.observe.Monitor and auxiliary state objects.

class Unit(cell: Cell, state: Module, monitors: dict[str, Monitor])[source]

Bases: Module

Trainable units.

cell

registered cell.

Type:

Cell

state

auxiliary state.

Type:

nn.Module

monitors

associated monitors.

Type:

nn.ModuleDict

Parameters:
  • cell (Cell) – registered cell.

  • state (nn.Module) – auxiliary state.

  • monitors (dict[str, Monitor]) – associated monitors.

get_unit(name: str) Unit[source]

Gets a trainable unit.

This can be used if a single trainer should handle training on different devices. The returned module dictionary can then be altered in-place with to() in order to move a cell (cell), its auxiliary state (state), and monitors (monitors) used by the trainer to a different device, or change the used data type.

Calling to() on the trainer itself will apply to all monitors and auxiliary states, but not to any cells.

Parameters:

name (str) – name of the cell to get alongside its auxiliary state.

Returns:

specified cell, auxiliary state, and monitors.

Return type:

IndependentCellTrainer.Unit

abstract register_cell(name: str, cell: Cell, **kwargs) Unit[source]

Adds a cell with any required state.

Parameters:
  • name (str) – name of the cell to add.

  • cell (Cell) – cell to add.

Returns:

specified cell, auxiliary state, and monitors, as returned by get_unit().

Return type:

IndependentCellTrainer.Unit

Raises:

NotImplementedErrorregister_cell must be implemented by the subclass.