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:
Module2D 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. IfNone, same asin_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 toTrue. Default:True.instance_norm (
bool) – Instance norm is used if set toTrue. Default:False.dense_connect (
int) – Number of dense connections. Default:0.replication_padding (
bool) – If set toTruereplication 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.Tensortensor. (Input)
previous_state (
Tensor) – torch.Tensorstate. (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:
ModuleNormalized 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) – intchannels. (Number of hidden)
hidden_channels (
int) – intchannels.
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) – intDefault –
gru_kernel_size – int
Default
orthogonal_initialization (
bool) – boolDefault – True.
instance_norm (
bool) – boolDefault – False.
dense_connect (
int) – intconnections. (Number of dense)
replication_padding (
bool) – boolapplied. (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]
- forward(cell_input, previous_state)[source]#
Computes
NormConv2dGRUforward 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.Tensortensor. (Input)
previous_state (
Tensor) – torch.Tensorstate. (Tensor of previous hidden)
- Returns:
(torch.Tensor, torch.Tensor) Output and new states.
- Return type:
out, new_states