MCPcopy Create free account
hub / github.com/ASLP-lab/OSUM / __init__

Method __init__

OSUM/wenet/ctl_model/encoder.py:29–74  ·  view source on GitHub ↗

Construct DualTransformerEncoder Support both the full context mode and the streaming mode separately

(
        self,
        input_size: int,
        output_size: int = 256,
        attention_heads: int = 4,
        linear_units: int = 2048,
        num_blocks: int = 6,
        dropout_rate: float = 0.1,
        positional_dropout_rate: float = 0.1,
        attention_dropout_rate: float = 0.0,
        input_layer: str = "conv2d",
        pos_enc_layer_type: str = "abs_pos",
        normalize_before: bool = True,
        static_chunk_size: int = 0,
        use_dynamic_chunk: bool = False,
        global_cmvn: torch.nn.Module = None,
        use_dynamic_left_chunk: bool = False,
        query_bias: bool = True,
        key_bias: bool = True,
        value_bias: bool = True,
        activation_type: str = "relu",
        gradient_checkpointing: bool = False,
        use_sdpa: bool = False,
        layer_norm_type: str = 'layer_norm',
        norm_eps: float = 1e-5,
        n_kv_head: Optional[int] = None,
        head_dim: Optional[int] = None,
        selfattention_layer_type: str = "selfattn",
        mlp_type: str = 'position_wise_feed_forward',
        mlp_bias: bool = True,
        n_expert: int = 8,
        n_expert_activated: int = 2,
    )

Source from the content-addressed store, hash-verified

27 """Transformer encoder module."""
28
29 def __init__(
30 self,
31 input_size: int,
32 output_size: int = 256,
33 attention_heads: int = 4,
34 linear_units: int = 2048,
35 num_blocks: int = 6,
36 dropout_rate: float = 0.1,
37 positional_dropout_rate: float = 0.1,
38 attention_dropout_rate: float = 0.0,
39 input_layer: str = "conv2d",
40 pos_enc_layer_type: str = "abs_pos",
41 normalize_before: bool = True,
42 static_chunk_size: int = 0,
43 use_dynamic_chunk: bool = False,
44 global_cmvn: torch.nn.Module = None,
45 use_dynamic_left_chunk: bool = False,
46 query_bias: bool = True,
47 key_bias: bool = True,
48 value_bias: bool = True,
49 activation_type: str = "relu",
50 gradient_checkpointing: bool = False,
51 use_sdpa: bool = False,
52 layer_norm_type: str = 'layer_norm',
53 norm_eps: float = 1e-5,
54 n_kv_head: Optional[int] = None,
55 head_dim: Optional[int] = None,
56 selfattention_layer_type: str = "selfattn",
57 mlp_type: str = 'position_wise_feed_forward',
58 mlp_bias: bool = True,
59 n_expert: int = 8,
60 n_expert_activated: int = 2,
61 ):
62 """ Construct DualTransformerEncoder
63 Support both the full context mode and the streaming mode separately
64 """
65 super().__init__(input_size, output_size, attention_heads,
66 linear_units, num_blocks, dropout_rate,
67 positional_dropout_rate, attention_dropout_rate,
68 input_layer, pos_enc_layer_type, normalize_before,
69 static_chunk_size, use_dynamic_chunk, global_cmvn,
70 use_dynamic_left_chunk, query_bias, key_bias,
71 value_bias, activation_type, gradient_checkpointing,
72 use_sdpa, layer_norm_type, norm_eps, n_kv_head,
73 head_dim, selfattention_layer_type, mlp_type,
74 mlp_bias, n_expert, n_expert_activated)
75
76 def forward_full(
77 self,

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected