espnet.nets.pytorch_backend.transformer.subsampling.Conv2dSubsampling
Less than 1 minute
espnet.nets.pytorch_backend.transformer.subsampling.Conv2dSubsampling
class espnet.nets.pytorch_backend.transformer.subsampling.Conv2dSubsampling(idim, odim, dropout_rate, pos_enc=None)
Bases: Module
Convolutional 2D subsampling (to 1/4 length).
- Parameters:
- idim (int) – Input dimension.
- odim (int) – Output dimension.
- dropout_rate (float) – Dropout rate.
- pos_enc (torch.nn.Module) – Custom position encoding layer.
Construct an Conv2dSubsampling object.
forward(x, x_mask)
Subsample x.
Parameters:
- x (torch.Tensor) – Input tensor (#batch, time, idim).
- x_mask (torch.Tensor) – Input mask (#batch, 1, time).
Returns: Subsampled tensor (#batch, time’, odim), : where time’ = time // 4.
torch.Tensor: Subsampled mask (#batch, 1, time’), : where time’ = time // 4.
Return type: torch.Tensor