Get an initial hypothesis data. Args: x (torch.Tensor): The encoder output feature Returns: Hypothesis: The initial hypothesis.
(self, x: torch.Tensor)
| 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: |
no test coverage detected