May 2019
Intermediate to advanced
272 pages
7h 19m
English
We wrap the generator and discriminator methods that are to be used during training in the following function:
def GAN(G, D, z_dim, n_labels, resolution, n_channels): # create D(G(z)) and set current block G_train = Sequential([G, D]) G_train.cur_block = G.cur_block # instantiate symbolic variables for inputs shape = D.get_input_shape_at(0)[1:] gen_input, real_input = Input(shape), Input(shape) interpolation = Input(shape) # define the wasserstein distance and grad norm w_distance = WassersteinDistance()([D(gen_input), D(real_input)]) g_norm = GradNorm()([D(interpolation), interpolation]) # use w_distance, g_norm and output of D on reals for computing the loss D_train = Model([real_input, gen_input, interpolation], [w_distance, g_norm, ...
Read now
Unlock full access