May 2019
Intermediate to advanced
272 pages
7h 19m
English
To conclude, we define the training loop itself:
for i in range(n_iterations): # we are performing D updates only, fix G weights D.trainable = True G.trainable = False for j in range(N_CRITIC_ITERS): z = np.random.normal(0, 1, size=(batch_size, z_dim)) real_batch = next(data_iterator) losses_d = D_model.train_on_batch( [real_batch, z], [minus_ones, ones, dummy]) # we are performing G updates only, fix D weights D.trainable = False G.trainable = True z = np.random.normal(0, 1, size=(batch_size, z_dim)) loss_g = G_model.train_on_batch(z, minus_ones) if (i % iters_per_checkpoint) == 0: G.trainable = False fake_text = G.predict(z_fixed) log_text(sample(fake_text, id_to_token, word_join), 'fake', i, logger) ...
Read now
Unlock full access