def build_discriminator(self): 
     #self.logits_DIV2K_color, _ = modules.discriminator_network(self.DIV2K_patch, var_scope = 'discriminator_color', preprocess = 'blur')
     self.logits_DIV2K_color, _ = modules.discriminator_network(self.DIV2K_patch, var_scope = 'discriminator_color', preprocess = 'none')
     self.logits_DIV2K_texture, _ = modules.discriminator_network(self.DIV2K_patch, var_scope = 'discriminator_texture', preprocess = 'gray')
     
     #self.logits_enhanced_color, _ = modules.discriminator_network(self.enhanced_patch, var_scope = 'discriminator_color', preprocess = 'blur')
     self.logits_enhanced_color, _ = modules.discriminator_network(self.enhanced_patch, var_scope = 'discriminator_color', preprocess = 'none')
     self.logits_enhanced_texture, _ = modules.discriminator_network(self.enhanced_patch, var_scope = 'discriminator_texture', preprocess = 'gray')
     
     #_, self.prob = modules.discriminator_network(self.phone_test)
        
     variables = tf.trainable_variables()
     self.d_var_color = [x for x in variables if 'discriminator_color' in x.name]
     print("Completed building color discriminator. Number of variables:",len(self.d_var_color))
     
     d_loss_real_color = tf.reduce_mean(sigmoid_cross_entropy_with_logits(self.logits_DIV2K_color, tf.ones_like(self.logits_DIV2K_color)))
     d_loss_fake_color = tf.reduce_mean(sigmoid_cross_entropy_with_logits(self.logits_enhanced_color, tf.zeros_like(self.logits_enhanced_color)))
     
     self.d_loss_color = d_loss_real_color + d_loss_fake_color
     self.D_optimizer_color = tf.train.AdamOptimizer(self.config.learning_rate).minimize(self.d_loss_color, var_list=self.d_var_color)
     
     self.d_var_texture = [x for x in variables if 'discriminator_texture' in x.name]
     print("Completed building texture discriminator. Number of variables:",len(self.d_var_texture))
     
     d_loss_real_texture = tf.reduce_mean(sigmoid_cross_entropy_with_logits(self.logits_DIV2K_texture, tf.ones_like(self.logits_DIV2K_texture)))
     d_loss_fake_texture = tf.reduce_mean(sigmoid_cross_entropy_with_logits(self.logits_enhanced_texture, tf.zeros_like(self.logits_enhanced_texture)))
     
     self.d_loss_texture = d_loss_real_texture + d_loss_fake_texture
     self.D_optimizer_texture = tf.train.AdamOptimizer(self.config.learning_rate).minimize(self.d_loss_texture, var_list=self.d_var_texture)
Пример #2
0
    def build_discriminator(self):
        self.logits_phone, _ = modules.discriminator_network(
            self.phone_patch, var_scope='discriminator')
        self.logits_dslr, _ = modules.discriminator_network(
            self.dslr_patch, var_scope='discriminator')
        self.logits_enhanced, _ = modules.discriminator_network(
            self.enhanced_patch, var_scope='discriminator')

        _, self.prob = modules.discriminator_network(self.phone_test)

        variables = tf.trainable_variables()
        self.d_var = [x for x in variables if 'discriminator' in x.name]
        print("Completed building discriminator. Number of variables:",
              len(self.d_var))

        d_loss_real = tf.reduce_mean(
            sigmoid_cross_entropy_with_logits(self.logits_dslr,
                                              tf.ones_like(self.logits_dslr)))
        d_loss_fake = tf.reduce_mean(
            sigmoid_cross_entropy_with_logits(self.logits_phone,
                                              tf.zeros_like(
                                                  self.logits_phone)))

        self.d_loss = d_loss_real + d_loss_fake
        self.D_optimizer = tf.train.AdamOptimizer(
            self.config.learning_rate).minimize(self.d_loss,
                                                var_list=self.d_var)
Пример #3
0
    def build_discriminator_unit(self, generated_patch, actual_patch,
                                 preprocess, scope_name):
        actual, _ = modules.discriminator_network(actual_patch,
                                                  var_scope=scope_name,
                                                  preprocess=preprocess)
        fake, _ = modules.discriminator_network(generated_patch,
                                                var_scope=scope_name,
                                                preprocess=preprocess)
        variables = tf.trainable_variables()
        d_vars = [x for x in variables if scope_name in x.name]
        print("Completed building %s discriminator. Number of variables = %d" %
              (scope_name, len(d_vars)))

        loss_real = tf.reduce_mean(
            sigmoid_cross_entropy_with_logits(actual, tf.ones_like(actual)))
        loss_fake = tf.reduce_mean(
            sigmoid_cross_entropy_with_logits(fake, tf.zeros_like(fake)))
        total_loss = loss_real + loss_fake

        return total_loss, d_vars, actual, fake