May 2019
Intermediate to advanced
272 pages
7h 19m
English
The following functions are helper functions that can be used while computing the Wasserstein GAN loss with Gradient Penalty.
The first function is as follows:
def get_interpolated_images(real_samples, fake_samples): p = np.random.uniform(0, 1, size=(real_samples.shape[0], 1, 1, 1)) return p * real_samples + (1-p) * fake_samples
The next three functions are necessary for computing the generator's loss, which is the negative average of the discriminator's output on fake samples, and to compute the discriminator's Wasserstein distance and penalty terms. In this implementation, we take advantage of the fact that the expected value is a linear operator and, therefore, we take the mean of the differences instead of the difference ...
Read now
Unlock full access