espnet2.legacy.nets.pytorch_backend.transducer.conv1d_nets.Conv1d
espnet2.legacy.nets.pytorch_backend.transducer.conv1d_nets.Conv1d
class espnet2.legacy.nets.pytorch_backend.transducer.conv1d_nets.Conv1d(idim: int, odim: int, kernel_size: int | Tuple, stride: int | Tuple = 1, dilation: int | Tuple = 1, groups: int | Tuple = 1, bias: bool = True, batch_norm: bool = False, relu: bool = True, dropout_rate: float = 0.0)
Bases: Module
1D convolution module for custom encoder.
- Parameters:
- idim β Input dimension.
- odim β Output dimension.
- kernel_size β Size of the convolving kernel.
- stride β Stride of the convolution.
- dilation β Spacing between the kernel points.
- groups β Number of blocked connections from input channels to output channels.
- bias β Whether to add a learnable bias to the output.
- batch_norm β Whether to use batch normalization after convolution.
- relu β Whether to use a ReLU activation after convolution.
- dropout_rate β Dropout rate.
Construct a Conv1d module object.
create_new_mask(mask: Tensor) β Tensor
Create new mask.
- Parameters:mask β Mask of input sequences. (B, 1, T)
- Returns: Mask of output sequences. (B, 1, sub(T))
- Return type: mask
create_new_pos_embed(pos_embed: Tensor) β Tensor
Create new positional embedding vector.
- Parameters:pos_embed β Input sequences positional embedding. (B, 2 * (T - 1), D_att)
- Returns: Output sequences positional embedding. : (B, 2 * (sub(T) - 1), D_att)
- Return type: pos_embed
forward(sequence: Tensor | Tuple[Tensor, Tensor], mask: Tensor) β Tuple[Tensor | Tuple[Tensor, Tensor], Tensor]
Forward ConvEncoderLayer module object.
Parameters:
sequence β
Input sequences. (B, T, D_in)
or (B, T, D_in), (B, 2 * (T - 1), D_att)
mask β Mask of input sequences. (B, 1, T)
Returns: Output sequences. : (B, sub(T), D_out) : or (B, sub(T), D_out), (B, 2 * (sub(T) - 1), D_att)
mask: Mask of output sequences. (B, 1, sub(T))
Return type: sequence
