espnet.nets.pytorch_backend.maskctc.mask.square_mask
Less than 1 minute
espnet.nets.pytorch_backend.maskctc.mask.square_mask
espnet.nets.pytorch_backend.maskctc.mask.square_mask(ys_in_pad, ignore_id)
Create attention mask to avoid attending on padding tokens.
- Parameters:
- ys_pad (torch.Tensor) – batch of padded target sequences (B, Lmax)
- ignore_id (int) – index of padding
- dtype (torch.dtype) – result dtype
- Return type: torch.Tensor (B, Lmax, Lmax)