February 2018
Intermediate to advanced
450 pages
11h 27m
English
Now let's kick off the training process and see how GANs will manage to generate images similar to the MNIST ones:
train_batch_size = 100num_epochs = 100generated_samples = []model_losses = []saver = tf.train.Saver(var_list = gen_vars)with tf.Session() as sess: sess.run(tf.global_variables_initializer()) for e in range(num_epochs): for ii in range(mnist_dataset.train.num_examples//train_batch_size): input_batch = mnist_dataset.train.next_batch(train_batch_size) # Get images, reshape and rescale to pass to D input_batch_images = input_batch[0].reshape((train_batch_size, 784)) input_batch_images = input_batch_images*2 - 1 # Sample random noise for G gen_batch_z = np.random.uniform(-1, 1, size=(train_batch_size, gen_z_size)) ...
Read now
Unlock full access