direct.nn.recurrent package#

Submodules#

direct.nn.recurrent.recurrent module#

class direct.nn.recurrent.recurrent.Conv2dGRU(in_channels, hidden_channels, out_channels=None, num_layers=2, gru_kernel_size=1, orthogonal_initialization=True, instance_norm=False, dense_connect=0, replication_padding=True)[source]#

Bases: Module

2D Convolutional GRU Network.

__init__(in_channels, hidden_channels, out_channels=None, num_layers=2, gru_kernel_size=1, orthogonal_initialization=True, instance_norm=False, dense_connect=0, replication_padding=True)[source]#

Inits Conv2dGRU.

Parameters:
  • in_channels (int) – Number of input channels.

  • hidden_channels (int) – Number of hidden channels.

  • out_channels (Optional[int]) – Number of output channels. If None, same as in_channels. Default: None.

  • num_layers (int) – Number of layers. Default: 2.

  • gru_kernel_size – Size of the GRU kernel. Default: 1.

  • orthogonal_initialization (bool) – Orthogonal initialization is used if set to True. Default: True.

  • instance_norm (bool) – Instance norm is used if set to True. Default: False.

  • dense_connect (int) – Number of dense connections. Default: 0.

  • replication_padding (bool) – If set to True replication padding is applied. Default: True.

forward(cell_input, previous_state)[source]#

Computes Conv2dGRU forward pass given tensors cell_input and previous_state.

Parameters:
  • cell_input (Tensor) – torch.Tensor

  • tensor. (Input)

  • previous_state (Tensor) – torch.Tensor

  • state. (Tensor of previous hidden)

Returns:

(torch.Tensor, torch.Tensor) Output and new states.

Return type:

out, new_states

class direct.nn.recurrent.recurrent.NormConv2dGRU(in_channels, hidden_channels, out_channels=None, num_layers=2, gru_kernel_size=1, orthogonal_initialization=True, instance_norm=False, dense_connect=0, replication_padding=True, norm_groups=2)[source]#

Bases: Module

Normalized 2D Convolutional GRU Network.

Normalization methods adapted from NormUnet of [1].

References:

__init__(in_channels, hidden_channels, out_channels=None, num_layers=2, gru_kernel_size=1, orthogonal_initialization=True, instance_norm=False, dense_connect=0, replication_padding=True, norm_groups=2)[source]#

Inits NormConv2dGRU.

Parameters:
  • in_channels (int) – int

  • channels. (Number of hidden)

  • hidden_channels (int) – int

  • channels.

  • out_channels (Optional[int]) – Optional[int]

  • None (Number of output channels. If) – None.

  • Default (Instance norm is used if set to True.) – None.

  • num_layers (int) – int

  • Default

  • gru_kernel_size – int

  • Default

  • orthogonal_initialization (bool) – bool

  • Default – True.

  • instance_norm (bool) – bool

  • Default – False.

  • dense_connect (int) – int

  • connections. (Number of dense)

  • replication_padding (bool) – bool

  • applied. (If set to true replication padding is)

  • norm_groups (int) – int,

  • groups. (Number of normalization)

static norm(input_data, num_groups)[source]#

Performs group normalization.

Return type:

Tuple[Tensor, Tensor, Tensor]

static unnorm(input_data, mean, std, num_groups)[source]#
Return type:

Tensor

forward(cell_input, previous_state)[source]#

Computes NormConv2dGRU forward pass given tensors cell_input and previous_state.

It performs group normalization on the input before the forward pass to the Conv2dGRU. Output of Conv2dGRU is then un-normalized.

Parameters:
  • cell_input (Tensor) – torch.Tensor

  • tensor. (Input)

  • previous_state (Tensor) – torch.Tensor

  • state. (Tensor of previous hidden)

Returns:

(torch.Tensor, torch.Tensor) Output and new states.

Return type:

out, new_states

Module contents#