def _loss(self):
        """Builds the loss part of the graph.."""
        # Loss terms

        raw_reconstruction_error = slim.flatten(
            tf.reduce_mean(
                tf.abs(self.enc_reconstruction - self.real_data),
                axis=1,
            )
        )
        tf.summary.histogram("raw reconstruction error", raw_reconstruction_error)

        img_rec_loss = self.rec_loss_scale * tf.reduce_mean(tf.nn.relu(raw_reconstruction_error - self.rec_margin))
        tf.summary.scalar("losses/margin_rec", img_rec_loss)

        self.enc_rec_faking_loss = generator_loss(
            "dcgan",
            self.disc_enc_rec,
        )

        self.enc_rec_disc_loss = self.rec_disc_loss_scale * discriminator_loss(
            "dcgan",
            self.disc_real,
            self.disc_enc_rec,
        )

        tf.summary.scalar("losses/enc_recon_faking_disc", self.enc_rec_faking_loss)

        self.latent_reg_loss = self.latent_reg_loss_scale * tf.reduce_mean(tf.square(self.encoder_latent_before))
        tf.summary.scalar("losses/latent_reg", self.latent_reg_loss)

        self.enc_cost = img_rec_loss + self.rec_disc_loss_scale * self.enc_rec_faking_loss + self.latent_reg_loss
        self.discriminator_loss = self.enc_rec_disc_loss
        tf.summary.scalar("losses/encoder_loss", self.enc_cost)
        tf.summary.scalar("losses/discriminator_loss", self.enc_rec_disc_loss)
Builds the loss part of the graph..
examples/inverse_gan_author_utils.py