MCPcopy Create free account
hub / github.com/espnet/espnet / __init__

Method __init__

espnet2/asr/decoder/transformer_decoder.py:721–775  ·  view source on GitHub ↗
(
        self,
        vocab_size: int,
        encoder_output_size: int,
        attention_heads: int = 4,
        linear_units: int = 2048,
        num_blocks: int = 6,
        dropout_rate: float = 0.1,
        positional_dropout_rate: float = 0.1,
        self_attention_dropout_rate: float = 0.0,
        src_attention_dropout_rate: float = 0.0,
        input_layer: str = "embed",
        use_output_layer: bool = True,
        pos_enc_class=PositionalEncoding,
        normalize_before: bool = True,
        concat_after: bool = False,
        use_speech_attn: bool = True,
    )

Source from the content-addressed store, hash-verified

719class TransformerMDDecoder(BaseTransformerDecoder):
720 @typechecked
721 def __init__(
722 self,
723 vocab_size: int,
724 encoder_output_size: int,
725 attention_heads: int = 4,
726 linear_units: int = 2048,
727 num_blocks: int = 6,
728 dropout_rate: float = 0.1,
729 positional_dropout_rate: float = 0.1,
730 self_attention_dropout_rate: float = 0.0,
731 src_attention_dropout_rate: float = 0.0,
732 input_layer: str = "embed",
733 use_output_layer: bool = True,
734 pos_enc_class=PositionalEncoding,
735 normalize_before: bool = True,
736 concat_after: bool = False,
737 use_speech_attn: bool = True,
738 ):
739 super().__init__(
740 vocab_size=vocab_size,
741 encoder_output_size=encoder_output_size,
742 dropout_rate=dropout_rate,
743 positional_dropout_rate=positional_dropout_rate,
744 input_layer=input_layer,
745 use_output_layer=use_output_layer,
746 pos_enc_class=pos_enc_class,
747 normalize_before=normalize_before,
748 )
749
750 attention_dim = encoder_output_size
751 self.decoders = repeat(
752 num_blocks,
753 lambda lnum: DecoderLayer(
754 attention_dim,
755 MultiHeadedAttention(
756 attention_heads, attention_dim, self_attention_dropout_rate
757 ),
758 MultiHeadedAttention(
759 attention_heads, attention_dim, src_attention_dropout_rate
760 ),
761 PositionwiseFeedForward(attention_dim, linear_units, dropout_rate),
762 dropout_rate,
763 normalize_before,
764 concat_after,
765 (
766 MultiHeadedAttention(
767 attention_heads, attention_dim, src_attention_dropout_rate
768 )
769 if use_speech_attn
770 else None
771 ),
772 ),
773 )
774
775 self.use_speech_attn = use_speech_attn
776
777 def forward(
778 self,

Callers

nothing calls this directly

Calls 5

repeatFunction · 0.90
DecoderLayerClass · 0.90
__init__Method · 0.45

Tested by

no test coverage detected