Last active
May 14, 2020 13:05
-
-
Save jamescalam/1d4897bfa61bc7fc2fef76ef845c2f66 to your computer and use it in GitHub Desktop.
Methods used in the generator class for a DCGAN.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # this should be placed outside the class, as it will be used by the discriminator too | |
| cross_entropy = tf.keras.losses.BinaryCrossentropy(from_logits=True) | |
| # the following are contained within the Generator class | |
| def optimiser(self, learning_rate): | |
| self.opt = tf.optimizers.Adam(learning_rate) | |
| def loss(self, fake_preds): | |
| # calculate the loss with binary cross-entropy | |
| fake_loss = cross_entropy(tf.ones_like(fake_preds), fake_preds) | |
| # return the fake predictions loss | |
| return fake_loss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment