import tensorflow as tf

    # For printing layers shape
    self.training_end_points = self.end_points_D
    self.training_end_points.update(self.end_points_G)

    tf.summary.histogram("d", self.end_points_D['D_on_data'])
    tf.summary.histogram("d_", self.end_points_D['D_on_G'])
    tf.summary.image("G", G)

    d_label_smooth = self.cnf['d_label_smooth']  # 0.25
    self.d_loss_real = self._sigmoid_kl_with_logits(self.end_points_D['D_on_data_logits'],
                                                    1. - d_label_smooth)
    class_loss_weight = 1.
    self.d_loss_class = class_loss_weight * tf.nn.sparse_softmax_cross_entropy_with_logits(
        logits=self.end_points_D['class_logits'], labels=tf.to_int64(targets))
    self.test_loss = 1. - \
        tf.reduce_mean(tf.to_float(tf.nn.in_top_k(
            self.end_points_D_val['logits'], targets, 1)))
    self.error_rate = 1. - \
        tf.reduce_mean(tf.to_float(tf.nn.in_top_k(
            self.end_points_D['class_logits'], targets, 1)))
    if gpu_idx == 0:
      update = tf.assign(num_error_rate, num_error_rate + 1.)
      with tf.control_dependencies([update]):
        tc = tf.maximum(.01, 1. / num_error_rate)
      update = tf.assign(avg_error_rate, (1. - tc) * avg_error_rate + tc * self.error_rate)
      with tf.control_dependencies([update]):
        self.d_loss_class = tf.identity(self.d_loss_class)
    self.d_loss_fake = tf.nn.sigmoid_cross_entropy_with_logits(
        logits=self.end_points_D['D_on_G_logits'],
        labels=tf.zeros_like(self.end_points_D['D_on_G_logits']))
