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

Method init_hyp

funasr/models/transformer/search.py:111–133  ·  view source on GitHub ↗

Get an initial hypothesis data. Args: x (torch.Tensor): The encoder output feature Returns: Hypothesis: The initial hypothesis.

(self, x: torch.Tensor)

Source from the content-addressed store, hash-verified

109 )
110
111 def init_hyp(self, x: torch.Tensor) -> List[Hypothesis]:
112 """Get an initial hypothesis data.
113
114 Args:
115 x (torch.Tensor): The encoder output feature
116
117 Returns:
118 Hypothesis: The initial hypothesis.
119
120 """
121 init_states = dict()
122 init_scores = dict()
123 for k, d in self.scorers.items():
124 init_states[k] = d.init_state(x)
125 init_scores[k] = 0.0
126 return [
127 Hypothesis(
128 score=0.0,
129 scores=init_scores,
130 states=init_states,
131 yseq=torch.tensor([self.sos], device=x.device),
132 )
133 ]
134
135 @staticmethod
136 def append_token(xs: torch.Tensor, x: int) -> torch.Tensor:

Callers 1

forwardMethod · 0.95

Calls 2

HypothesisClass · 0.70
init_stateMethod · 0.45

Tested by

no test coverage detected