Ejemplo n.º 1
0
 def __init__(self, num_chars, hidden_channels, hidden_channels_ffn,
              num_heads):
     super().__init__()
     self.embed = nn.Embedding(num_chars, hidden_channels)
     self.pos_enc = PositionalEncoding(hidden_channels, dropout_p=0.1)
     self.FFT = FFTransformerBlock(hidden_channels, num_heads,
                                   hidden_channels_ffn, 2, 0.1)
     self.out_layer = nn.Conv1d(hidden_channels, 1, 1)
Ejemplo n.º 2
0
    def __init__(
        self,
        in_hidden_channels,
        out_channels,
        encoder_type="residual_conv_bn",
        encoder_params={
            "kernel_size": 4,
            "dilations": 4 * [1, 2, 4] + [1],
            "num_conv_blocks": 2,
            "num_res_blocks": 13
        },
        c_in_channels=0,
    ):
        super().__init__()
        self.out_channels = out_channels
        self.in_channels = in_hidden_channels
        self.hidden_channels = in_hidden_channels
        self.encoder_type = encoder_type
        self.c_in_channels = c_in_channels

        # init encoder
        if encoder_type.lower() == "relative_position_transformer":
            # text encoder
            # pylint: disable=unexpected-keyword-arg
            self.encoder = RelativePositionTransformerEncoder(
                in_hidden_channels, out_channels, in_hidden_channels,
                encoder_params)
        elif encoder_type.lower() == "residual_conv_bn":
            self.encoder = ResidualConv1dBNEncoder(in_hidden_channels,
                                                   out_channels,
                                                   in_hidden_channels,
                                                   encoder_params)
        elif encoder_type.lower() == "fftransformer":
            assert (
                in_hidden_channels == out_channels
            ), "[!] must be `in_channels` == `out_channels` when encoder type is 'fftransformer'"
            # pylint: disable=unexpected-keyword-arg
            self.encoder = FFTransformerBlock(in_hidden_channels,
                                              **encoder_params)
        else:
            raise NotImplementedError(" [!] unknown encoder type.")
Ejemplo n.º 3
0
    def __init__(self, in_channels, out_channels, params):

        super().__init__()
        self.transformer_block = FFTransformerBlock(in_channels, **params)
        self.postnet = nn.Conv1d(in_channels, out_channels, 1)