July 2019
Intermediate to advanced
512 pages
19h 39m
English
We set the digit (label) to generate as 7:
label_to_generate = 7onehot = np.eye(10)
Set the number of iterations:
for epoch in range(num_epochs): for i in range(len(images) // batch_size):
Sample images based on the batch size:
batch_image = images[i * batch_size:(i + 1) * batch_size]
Sample the condition that is, digit we want to generate:
batch_c = labels[i * batch_size:(i + 1) * batch_size]
Sample noise:
batch_noise = np.random.normal(0, 1, (batch_size, 100))
Train the generator and compute the generator loss:
generator_loss, _ = session.run([D_loss, D_optimizer], {x: batch_image, c: batch_c, z: batch_noise})
Train the discriminator and compute the discriminator loss:
discriminator_loss, _ = session.run([G_loss, ...
Read now
Unlock full access