def __init__(self):
    self.img_rows = 28
    self.img_cols = 28
    self.channels = 1
    self.img_shape = (self.img_rows, self.img_cols, self.channels)
    self.latent_dim = 100
    self.n_critic = 5
    optimizer = RMSprop(lr=5e-05)
    self.generator = self.build_generator()
    self.critic = self.build_critic()
    self.generator.trainable = False
    real_img = Input(shape=self.img_shape)
    z_disc = Input(shape=(self.latent_dim,))
    fake_img = self.generator(z_disc)
    fake = self.critic(fake_img)
    valid = self.critic(real_img)
    interpolated_img = RandomWeightedAverage()([real_img, fake_img])
    validity_interpolated = self.critic(interpolated_img)
    partial_gp_loss = partial(self.gradient_penalty_loss, averaged_samples=interpolated_img)
    partial_gp_loss.__name__ = 'gradient_penalty'
    self.critic_model = Model(inputs=[real_img, z_disc], outputs=[valid, fake, validity_interpolated])
    self.critic_model.compile(loss=[self.wasserstein_loss, self.wasserstein_loss, partial_gp_loss], optimizer=optimizer, loss_weights=[1, 1, 10])
    self.critic.trainable = False
    self.generator.trainable = True
    z_gen = Input(shape=(self.latent_dim,))
    img = self.generator(z_gen)
    valid = self.critic(img)
    self.generator_model = Model(z_gen, valid)
    self.generator_model.compile(loss=self.wasserstein_loss, optimizer=optimizer)
def __init__(self):
    self.img_rows = 28
    self.img_cols = 28
    self.channels = 1
    self.img_shape = (self.img_rows, self.img_cols, self.channels)
    self.latent_dim = 100
    self.n_critic = 5
    optimizer = RMSprop(lr=5e-05)
    self.generator = self.build_generator()
    self.critic = self.build_critic()
    self.generator.trainable = False
    real_img = Input(shape=self.img_shape)
    z_disc = Input(shape=(self.latent_dim,))
    fake_img = self.generator(z_disc)
    fake = self.critic(fake_img)
    valid = self.critic(real_img)
    interpolated_img = RandomWeightedAverage()([real_img, fake_img])
    validity_interpolated = self.critic(interpolated_img)
    partial_gp_loss = partial(self.gradient_penalty_loss, averaged_samples=interpolated_img)
    partial_gp_loss.__name__ = 'gradient_penalty'
    self.critic_model = Model(inputs=[real_img, z_disc], outputs=[valid, fake, validity_interpolated])
    self.critic_model.compile(loss=[self.wasserstein_loss, self.wasserstein_loss, partial_gp_loss], optimizer=optimizer, loss_weights=[1, 1, 10])
    self.critic.trainable = False
    self.generator.trainable = True
    z_gen = Input(shape=(self.latent_dim,))
    img = self.generator(z_gen)
    valid = self.critic(img)
    self.generator_model = Model(z_gen, valid)
    self.generator_model.compile(loss=self.wasserstein_loss, optimizer=optimizer)