MCPcopy Create free account
hub / github.com/modelscope/FunASR / __init__

Method __init__

funasr/models/ctc/model.py:21–87  ·  view source on GitHub ↗

Initialize Transformer. Args: specaug: TODO. specaug_conf: Configuration dict for specaug. normalize: TODO. normalize_conf: Configuration dict for normalize. encoder: TODO. encoder_co

(
        self,
        specaug: str = None,
        specaug_conf: dict = None,
        normalize: str = None,
        normalize_conf: dict = None,
        encoder: str = None,
        encoder_conf: dict = None,
        ctc_conf: dict = None,
        input_size: int = 80,
        vocab_size: int = -1,
        ignore_id: int = -1,
        blank_id: int = 0,
        sos: int = 1,
        eos: int = 2,
        length_normalized_loss: bool = False,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

19 """CTC-attention hybrid Encoder-Decoder model"""
20
21 def __init__(
22 self,
23 specaug: str = None,
24 specaug_conf: dict = None,
25 normalize: str = None,
26 normalize_conf: dict = None,
27 encoder: str = None,
28 encoder_conf: dict = None,
29 ctc_conf: dict = None,
30 input_size: int = 80,
31 vocab_size: int = -1,
32 ignore_id: int = -1,
33 blank_id: int = 0,
34 sos: int = 1,
35 eos: int = 2,
36 length_normalized_loss: bool = False,
37 **kwargs,
38 ):
39
40 """Initialize Transformer.
41
42 Args:
43 specaug: TODO.
44 specaug_conf: Configuration dict for specaug.
45 normalize: TODO.
46 normalize_conf: Configuration dict for normalize.
47 encoder: TODO.
48 encoder_conf: Configuration dict for encoder.
49 ctc_conf: Configuration dict for ctc.
50 input_size: Size/dimension parameter.
51 vocab_size: Size/dimension parameter.
52 ignore_id: TODO.
53 blank_id: TODO.
54 sos: TODO.
55 eos: TODO.
56 length_normalized_loss: TODO.
57 **kwargs: Additional keyword arguments.
58 """
59 super().__init__()
60
61 if specaug is not None:
62 specaug_class = tables.specaug_classes.get(specaug)
63 specaug = specaug_class(**specaug_conf)
64 if normalize is not None:
65 normalize_class = tables.normalize_classes.get(normalize)
66 normalize = normalize_class(**normalize_conf)
67 encoder_class = tables.encoder_classes.get(encoder)
68 encoder = encoder_class(input_size=input_size, **encoder_conf)
69 encoder_output_size = encoder.output_size()
70
71 if ctc_conf is None:
72 ctc_conf = {}
73 ctc = CTC(odim=vocab_size, encoder_output_size=encoder_output_size, **ctc_conf)
74
75 self.blank_id = blank_id
76 self.sos = sos if sos is not None else vocab_size - 1
77 self.eos = eos if eos is not None else vocab_size - 1
78 self.vocab_size = vocab_size

Callers

nothing calls this directly

Calls 2

CTCClass · 0.90
output_sizeMethod · 0.45

Tested by

no test coverage detected