models.generator.ModelGen#

class ModelGen(cfg: BaseConfig, in_channels: int = 2, init_weights: bool = True)[source]#

Bases: Module

Base class for model generators

Class BlockGen is used as a generation tool.

Child classes must define ways to process input and output data. Different variants are presented in classes models.backbone.BackboneGen, models.neck.NeckGen, models.head.HeadGen.

Warning

This class can only be used as a base class for inheritance.

Parameters:
  • cfg (BaseConfig) – Network Configuration Generator.

  • in_channels (int, optional) – Number of input channels. Defaults to 2.

  • init_weights (bool, optional) – If true apply weight initialization function. Defaults to True.

Methods

forward

Network pass for data containing time resolution

forward_impl

State-based network pass

Attributes

default_cfgs

List of configurations provided by default.

out_channels

The number of channels that will be after applying this block to a tensor with in_channels channels.

training

default_cfgs: Dict[str, ListGen] = {}#

List of configurations provided by default.

forward(X: Tensor)[source]#

Network pass for data containing time resolution

Parameters:

X (torch.Tensor) – Input tensor. Shape is Shape [ts, batch, channel, h, w].

Returns:

The resulting tensor and the list of new states.

Return type:

torch.Tensor,

forward_impl(X: Tensor, state: ListState | None = None)[source]#

State-based network pass

Parameters:
  • X (torch.Tensor) – Input tensor. Shape is Shape [batch, channel, h, w].

  • state (ListState | None, optional) – List of block layer states. Defaults to None.

Returns:

The resulting tensor and the list of new states.

Return type:

Tuple[torch.Tensor, ListState]

out_channels: int = 0#

The number of channels that will be after applying this block to a tensor with in_channels channels.