July 2019
Intermediate to advanced
512 pages
19h 39m
English
Let's begin the training. Define the number of batches, epochs, and learning rate:
num_batches = int(x_train.shape[0] / batch_size)steps = 0num_epcohs = 500lr = 0.00002
Define a helper function for generating and plotting the generated images:
def generate_new_samples(session, n_images, z_dim): z = tf.random_normal([1, z_dim], mean=0.0, stddev=1.0) is_training = tf.placeholder(tf.bool, [], name='training_bool') samples = session.run(generator(z, z_dim, batch_size, is_training, reuse=True),feed_dict={is_training: True}) img = (samples[0] * 255).astype(np.uint8) plt.imshow(img) plt.show()
Start the training:
with tf.Session() as session:
Initialize all variables:
session.run(tf.global_variables_initializer())
To execute ...
Read now
Unlock full access