Example #1
0
 def __init__(self):
     super(AudioEncoder, self).__init__()
     seq = SequentialMaker()
     seq.add_module(
         "conv_0",
         MaskedConv1d(Hyper.dim_f, Hyper.dim_d, 1, padding="causal"))
     seq.add_module("relu_0", nn.ReLU())
     seq.add_module("drop_0", nn.Dropout(Hyper.dropout))
     seq.add_module(
         "conv_1",
         MaskedConv1d(Hyper.dim_d, Hyper.dim_d, 1, padding="causal"))
     seq.add_module("relu_1", nn.ReLU())
     seq.add_module("drop_1", nn.Dropout(Hyper.dropout))
     seq.add_module(
         "relu_2",
         MaskedConv1d(Hyper.dim_d, Hyper.dim_d, 1, padding="causal"))
     seq.add_module("drop_2", nn.Dropout(Hyper.dropout))
     i = 3
     for _ in range(2):
         for j in range(4):
             seq.add_module(
                 "highway-conv_{}".format(i),
                 HighwayConv1d(Hyper.dim_d,
                               kernel_size=3,
                               dilation=3**j,
                               padding="causal"))
             seq.add_module("drop_{}".format(i), nn.Dropout(Hyper.dropout))
             i += 1
     for k in range(2):
         seq.add_module(
             "highway-conv_{}".format(i),
             HighwayConv1d(Hyper.dim_d,
                           kernel_size=3,
                           dilation=3,
                           padding="causal"))
         if k == 0:
             seq.add_module("drop_{}".format(i), nn.Dropout(Hyper.dropout))
         i += 1
     self.seq_ = seq()
Example #2
0
 def print_shape(self, input_shape):
     print("text-encode {")
     SequentialMaker.print_shape(self.seq_,
                                 torch.LongTensor(np.zeros(input_shape)),
                                 intent_size=2)
     print("}")
Example #3
0
 def print_shape(self, input_shape):
     print("super-resolution {")
     SequentialMaker.print_shape(self.seq_,
                                 torch.FloatTensor(np.zeros(input_shape)),
                                 intent_size=2)
     print("}")
Example #4
0
 def __init__(self):
     super(SuperRes, self).__init__()
     seq = SequentialMaker()
     seq.add_module(
         "conv_0", MaskedConv1d(Hyper.dim_f, Hyper.dim_c, 1,
                                padding="same"))
     seq.add_module("drop_0", nn.Dropout(Hyper.dropout))
     i = 1
     for _ in range(1):
         for j in range(2):
             seq.add_module(
                 "highway-conv_{}".format(i),
                 HighwayConv1d(Hyper.dim_c,
                               kernel_size=3,
                               dilation=3**j,
                               padding="same"))
             seq.add_module("drop_{}".format(i), nn.Dropout(Hyper.dropout))
             i += 1
     for _ in range(2):
         seq.add_module(
             "deconv_{}".format(i),
             Deconv1d(Hyper.dim_c, Hyper.dim_c, 2, padding="same"))
         seq.add_module("drop_{}".format(i), nn.Dropout(Hyper.dropout))
         i += 1
         for j in range(2):
             seq.add_module(
                 "highway-conv_{}".format(i),
                 HighwayConv1d(Hyper.dim_c,
                               kernel_size=3,
                               dilation=3**j,
                               padding="same"))
             seq.add_module("drop_{}".format(i), nn.Dropout(Hyper.dropout))
             i += 1
     seq.add_module(
         "conv_{}".format(i),
         MaskedConv1d(Hyper.dim_c, Hyper.dim_c * 2, 1, padding="same"))
     seq.add_module("drop_{}".format(i), nn.Dropout(Hyper.dropout))
     i += 1
     for _ in range(2):
         seq.add_module(
             "highway-conv_{}".format(i),
             HighwayConv1d(Hyper.dim_c * 2,
                           kernel_size=3,
                           dilation=1,
                           padding="same"))
         seq.add_module("drop_{}".format(i), nn.Dropout(Hyper.dropout))
         i += 1
     F = Hyper.audio_nfft // 2 + 1
     seq.add_module("conv_{}".format(i),
                    MaskedConv1d(Hyper.dim_c * 2, F, 1, padding="same"))
     seq.add_module("drop_{}".format(i), nn.Dropout(Hyper.dropout))
     i += 1
     for _ in range(2):
         seq.add_module("conv_{}".format(i),
                        MaskedConv1d(F, F, 1, padding="same"))
         seq.add_module("relu_{}".format(i), nn.ReLU())
         seq.add_module("drop_{}".format(i), nn.Dropout(Hyper.dropout))
         i += 1
     seq.add_module("conv_{}".format(i),
                    MaskedConv1d(F, F, 1, padding="same"))
     self.seq_ = seq()
     self.sigmoid_ = nn.Sigmoid()
Example #5
0
 def print_shape(self, input_shape):
     print("audio-decoder {")
     SequentialMaker.print_shape(self.seq_,
                                 torch.FloatTensor(np.zeros(input_shape)),
                                 intent_size=2)
     print("}")
Example #6
0
 def __init__(self):
     super(TextEncoder, self).__init__()
     seq = SequentialMaker()
     seq.add_module(
         "char-embed",
         CharEmbed(len(Hyper.vocab), Hyper.dim_e, Hyper.vocab.find('P')))
     seq.add_module(
         "conv_0",
         MaskedConv1d(Hyper.dim_e, Hyper.dim_d * 2, 1, padding="same"))
     seq.add_module("relu_0", nn.ReLU())
     seq.add_module("drop_0", nn.Dropout(Hyper.dropout))
     seq.add_module(
         "conv_1",
         MaskedConv1d(Hyper.dim_d * 2, Hyper.dim_d * 2, 1, padding="same"))
     seq.add_module("drop_1", nn.Dropout(Hyper.dropout))
     i = 2
     for _ in range(2):
         for j in range(4):
             seq.add_module(
                 "highway-conv_{}".format(i),
                 HighwayConv1d(Hyper.dim_d * 2,
                               kernel_size=3,
                               dilation=3**j,
                               padding="same"))
             seq.add_module("drop_{}".format(i), nn.Dropout(Hyper.dropout))
             i += 1
     for j in [1, 0]:
         for k in range(2):
             seq.add_module(
                 "highway-conv_{}".format(i),
                 HighwayConv1d(Hyper.dim_d * 2,
                               kernel_size=3**j,
                               dilation=1,
                               padding="same"))
             if not (j == 0 and k == 1):
                 seq.add_module("drop_{}".format(i),
                                nn.Dropout(Hyper.dropout))
             i += 1
     self.seq_ = seq()