<filename>egs/librispeech/asr/simple_v1/model.py<gh_stars>0
from torch import Tensor
from torch import nn


class Model(nn.Module):
    """
    Args:
        num_features (int, optional): Number of input features (Default: ``40``).
        num_classes (int, optional): Number of output classes (Default: ``364``)
    """

    def __init__(self, num_features: int = 40, num_classes: int = 364) -> None:
        super(Model, self).__init__()
        self.acoustic_model = nn.Sequential(
            nn.Conv1d(in_channels=num_features,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=2000,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=2000, affine=False),
            nn.Conv1d(in_channels=2000,
                      out_channels=2000,
                      kernel_size=1,
                      stride=1,
                      padding=0), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=2000, affine=False),
            nn.Conv1d(in_channels=2000,
                      out_channels=num_classes,
                      kernel_size=1,
                      stride=1,
                      padding=0), nn.ReLU(inplace=True))

    def forward(self, x: Tensor) -> Tensor:
        r"""
        Args:
            x (torch.Tensor): Tensor of dimension (batch_size, num_features, input_length).

        Returns:
            Tensor: Predictor tensor of dimension (batch_size, number_of_classes, input_length).
        """

        x = self.acoustic_model(x)
        x = nn.functional.log_softmax(x, dim=1)
        return x

<filename>egs/librispeech/asr/simple_v1/model.py<gh_stars>0
from torch import Tensor
from torch import nn


class Model(nn.Module):
    """
    Args:
        num_features (int, optional): Number of input features (Default: ``40``).
        num_classes (int, optional): Number of output classes (Default: ``364``)
    """

    def __init__(self, num_features: int = 40, num_classes: int = 364) -> None:
        super(Model, self).__init__()
        self.acoustic_model = nn.Sequential(
            nn.Conv1d(in_channels=num_features,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=250,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=250, affine=False),
            nn.Conv1d(in_channels=250,
                      out_channels=2000,
                      kernel_size=3,
                      stride=1,
                      padding=1), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=2000, affine=False),
            nn.Conv1d(in_channels=2000,
                      out_channels=2000,
                      kernel_size=1,
                      stride=1,
                      padding=0), nn.ReLU(inplace=True),
            nn.BatchNorm1d(num_features=2000, affine=False),
            nn.Conv1d(in_channels=2000,
                      out_channels=num_classes,
                      kernel_size=1,
                      stride=1,
                      padding=0), nn.ReLU(inplace=True))

    def forward(self, x: Tensor) -> Tensor:
        r"""
        Args:
            x (torch.Tensor): Tensor of dimension (batch_size, num_features, input_length).

        Returns:
            Tensor: Predictor tensor of dimension (batch_size, number_of_classes, input_length).
        """

        x = self.acoustic_model(x)
        x = nn.functional.log_softmax(x, dim=1)
        return x

Args:         num_features (int, optional): Number of input features (Default: ``40``).         num_classes (int, optional): Number of output classes (Default: ``364``) Args:             x (torch.Tensor): Tensor of dimension (batch_size, num_features, input_length).          Returns:             Tensor: Predictor tensor of dimension (batch_size, number_of_classes, input_length).