mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-09-07 16:14:17 +00:00
minor fix of doc of pos_emb
This commit is contained in:
parent
5de9d0a19a
commit
61ecd3764d
@ -480,6 +480,7 @@ def main():
|
|||||||
|
|
||||||
# <blk> is defined in local/train_bpe_model.py
|
# <blk> is defined in local/train_bpe_model.py
|
||||||
params.blank_id = sp.piece_to_id("<blk>")
|
params.blank_id = sp.piece_to_id("<blk>")
|
||||||
|
params.unk_id = sp.piece_to_id("<unk>")
|
||||||
params.vocab_size = sp.get_piece_size()
|
params.vocab_size = sp.get_piece_size()
|
||||||
|
|
||||||
logging.info(params)
|
logging.info(params)
|
||||||
|
@ -550,8 +550,8 @@ class EmformerAttention(nn.Module):
|
|||||||
Cached attention value of left context from preceding computation,
|
Cached attention value of left context from preceding computation,
|
||||||
with shape (L, B, D).
|
with shape (L, B, D).
|
||||||
pos_emb (torch.Tensor):
|
pos_emb (torch.Tensor):
|
||||||
Position encoding embedding, with shape (PE, D).
|
Position encoding embedding, with shape (PE, D),
|
||||||
For infer mode, PE = L+2*U-1.
|
where PE = L + 2 * U - 1.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A tuple containing 4 tensors:
|
A tuple containing 4 tensors:
|
||||||
@ -1264,6 +1264,10 @@ class EmformerEncoder(nn.Module):
|
|||||||
right_context at the end.
|
right_context at the end.
|
||||||
"""
|
"""
|
||||||
U = x.size(0) - self.right_context_length
|
U = x.size(0) - self.right_context_length
|
||||||
|
|
||||||
|
# for query of [utterance] (i), key-value [utterance] (j),
|
||||||
|
# the max relative distance i - j is U - 1
|
||||||
|
# the min relative distance i - j is -(U - 1)
|
||||||
x, pos_emb = self.encoder_pos(x, pos_len=U, neg_len=U)
|
x, pos_emb = self.encoder_pos(x, pos_len=U, neg_len=U)
|
||||||
|
|
||||||
right_context = self._gen_right_context(x)
|
right_context = self._gen_right_context(x)
|
||||||
@ -1329,8 +1333,12 @@ class EmformerEncoder(nn.Module):
|
|||||||
f"expected size of {self.chunk_length + self.right_context_length} "
|
f"expected size of {self.chunk_length + self.right_context_length} "
|
||||||
f"for dimension 1 of x, but got {x.size(1)}."
|
f"for dimension 1 of x, but got {x.size(1)}."
|
||||||
)
|
)
|
||||||
|
|
||||||
pos_len = self.chunk_length + self.left_context_length
|
pos_len = self.chunk_length + self.left_context_length
|
||||||
neg_len = self.chunk_length
|
neg_len = self.chunk_length
|
||||||
|
# for query of [utterance] (i), key-value [left_context, utterance] (j),
|
||||||
|
# the max relative distance i - j is L + U - 1
|
||||||
|
# the min relative distance i - j is -(U - 1)
|
||||||
x, pos_emb = self.encoder_pos(x, pos_len=pos_len, neg_len=neg_len)
|
x, pos_emb = self.encoder_pos(x, pos_len=pos_len, neg_len=neg_len)
|
||||||
|
|
||||||
right_context = x[self.chunk_length :]
|
right_context = x[self.chunk_length :]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user