espnet2.asr.encoder.linear_encoder.LinearEncoder
Less than 1 minute
espnet2.asr.encoder.linear_encoder.LinearEncoder
class espnet2.asr.encoder.linear_encoder.LinearEncoder(input_size: int, output_size: int = 256, dropout_rate: float = 0.1, input_layer: str | None = 'conv2d', normalize_before: bool = True, padding_idx: int = -1)
Bases: AbsEncoder
Linear encoder module.
- Parameters:
- input_size – input dim
- output_size – dimension of attention
- linear_units – the number of units of position-wise feed forward
- dropout_rate – dropout rate
- input_layer – input layer type
- normalize_before – whether to use layer_norm before the first block
- padding_idx – padding_idx for input_layer=embed
Initializes internal Module state, shared by both nn.Module and ScriptModule.
forward(xs_pad: Tensor, ilens: Tensor, prev_states: Tensor | None = None) → Tuple[Tensor, Tensor, Tensor | None]
Embed positions in tensor.
- Parameters:
- xs_pad – input tensor (B, L, D)
- ilens – input length (B)
- prev_states – Not to be used now.
- Returns: position embedded tensor and mask
output_size() → int