Пример #1
0
    def FCDiscriminator_sampler(self, inputs, FC_DIM=512, n_layers=3):
        with tf.variable_scope('Discriminator') as scope:
            scope.reuse_variables()
            output = tf.reshape(inputs, [-1, self.num_neurons, self.num_bins])
            conv1d_II.set_weights_stdev(0.02)
            output, filters = conv1d_II.Conv1D('Input',
                                               self.num_neurons,
                                               self.num_features,
                                               self.kernel_width,
                                               output,
                                               stride=1,
                                               save_filter=True)
            output = tf.reshape(output,
                                [-1, self.num_features * self.num_bins])
            outputs_mat = [output]
            output = act_funct.LeakyReLULayer(
                '0', self.num_features * self.num_bins, FC_DIM, output)
            outputs_mat.append(output)
            for i in range(n_layers - 1):
                output = act_funct.LeakyReLULayer('{}'.format(i + 1), FC_DIM,
                                                  FC_DIM, output)
                outputs_mat.append(output)
            output = linear.Linear('Out', FC_DIM, 1, output)
            conv1d_II.unset_weights_stdev()

            return tf.reshape(output, [-1]), [filters], outputs_mat
Пример #2
0
    def DCGANDiscriminator_sampler(self, inputs):
        kernel_width = self.width_kernel  # in the time dimension
        num_features = self.num_features
        #neurons are treated as different channels
        output = tf.reshape(inputs, [-1, self.num_neurons, self.num_bins])
        #initialize weights
        conv1d_II.set_weights_stdev(0.02)
        deconv1d_II.set_weights_stdev(0.02)
        linear.set_weights_stdev(0.02)
        out_puts_mat = []
        filters_mat = []

        for ind_l in range(self.num_layers):
            if ind_l == 0:
                output, filters = conv1d_II.Conv1D(
                    'Discriminator.' + str(ind_l + 1),
                    self.num_neurons,
                    num_features * 2**(ind_l + 1),
                    kernel_width,
                    output,
                    stride=self.stride,
                    save_filter=True)
            else:
                output, filters = conv1d_II.Conv1D(
                    'Discriminator.' + str(ind_l + 1),
                    num_features * 2**(ind_l),
                    num_features * 2**(ind_l + 1),
                    kernel_width,
                    output,
                    stride=self.stride,
                    save_filter=True)
            output = act_funct.LeakyReLU(output)
            out_puts_mat.append(output)
            filters_mat.append(filters)

        output = tf.reshape(output, [-1, int(num_features * self.num_bins)])
        output = linear.Linear('Discriminator.Output',
                               int(num_features * self.num_bins), 1, output)
        #unset weights
        conv1d_II.unset_weights_stdev()
        deconv1d_II.unset_weights_stdev()
        linear.unset_weights_stdev()

        return tf.reshape(output, [-1]), filters_mat, out_puts_mat
Пример #3
0
    def DCGANDiscriminator(self, inputs, print_arch=False):
        kernel_width = self.width_kernel  # in the time dimension
        num_features = self.num_features
        #neurons are treated as different channels
        output = tf.reshape(inputs, [-1, self.num_neurons, self.num_bins])
        conv1d_II.set_weights_stdev(0.02)
        deconv1d_II.set_weights_stdev(0.02)
        linear.set_weights_stdev(0.02)
        if print_arch:
            print('DISCRIMINATOR. -------------------------------')
            print(str(output.get_shape()) + ' input')
        for ind_l in range(self.num_layers):
            if ind_l == 0:
                output = conv1d_II.Conv1D('Discriminator.' + str(ind_l + 1),
                                          self.num_neurons,
                                          int(num_features * 2**(ind_l + 1)),
                                          int(kernel_width),
                                          output,
                                          stride=self.stride)
            else:
                output = conv1d_II.Conv1D('Discriminator.' + str(ind_l + 1),
                                          int(num_features * 2**(ind_l)),
                                          int(num_features * 2**(ind_l + 1)),
                                          int(kernel_width),
                                          output,
                                          stride=self.stride)
            output = act_funct.LeakyReLU(output)
            if print_arch:
                print(str(output.get_shape()) + ' layer ' + str(ind_l + 1))

        output = tf.reshape(output, [-1, int(num_features * self.num_bins)])
        if print_arch:
            print(str(output.get_shape()) + ' fully connected layer')
        output = linear.Linear('Discriminator.Output',
                               int(num_features * self.num_bins), 1, output)
        if print_arch:
            print(str(output.get_shape()) + ' output')
        conv1d_II.unset_weights_stdev()
        deconv1d_II.unset_weights_stdev()
        linear.unset_weights_stdev()

        return tf.reshape(output, [-1])
Пример #4
0
 def FCDiscriminator(self, inputs, FC_DIM=512, n_layers=3):
     output = tf.reshape(inputs, [-1, self.num_neurons, self.num_bins])
     conv1d_II.set_weights_stdev(0.02)
     output = conv1d_II.Conv1D('Discriminator.Input',
                               self.num_neurons,
                               self.num_features,
                               self.kernel_width,
                               output,
                               stride=1)
     output = tf.reshape(output, [-1, self.num_features * self.num_bins])
     output = act_funct.LeakyReLULayer('Discriminator.0',
                                       self.num_features * self.num_bins,
                                       FC_DIM, output)
     for i in range(n_layers - 1):
         output = act_funct.LeakyReLULayer('Discriminator.{}'.format(i + 1),
                                           FC_DIM, FC_DIM, output)
     output = linear.Linear('Discriminator.Out', FC_DIM, 1, output)
     conv1d_II.unset_weights_stdev()
     return tf.reshape(output, [-1])