(model, **kwargs)
Adds model summaries.

  This function adds several useful summaries during training:
  - fake_images: A grid of fake images based on random latent vectors.
  - interp_images: A grid of fake images based on interpolated latent vectors.
  - real_images_blend: A grid of real images.
  - summaries for `gan_model` losses, variable distributions etc.

  Args:
    model: An model object having all information of progressive GAN model,
        e.g. the return of build_model().
    **kwargs: A dictionary of
      'fake_grid_size': The fake image grid size for summaries.
      'interp_grid_size': The latent space interpolated image grid size for
          summaries.
      'colors': Number of image channels.
      'latent_vector_size': An integer of latent vector size.
Adds model summaries.
Adds model summaries .
def add_model_summaries(model, **kwargs):
  """Adds model summaries.

  This function adds several useful summaries during training:
  - fake_images: A grid of fake images based on random latent vectors.
  - interp_images: A grid of fake images based on interpolated latent vectors.
  - real_images_blend: A grid of real images.
  - summaries for `gan_model` losses, variable distributions etc.

  Args:
    model: An model object having all information of progressive GAN model,
        e.g. the return of build_model().
    **kwargs: A dictionary of
      'fake_grid_size': The fake image grid size for summaries.
      'interp_grid_size': The latent space interpolated image grid size for
          summaries.
      'colors': Number of image channels.
      'latent_vector_size': An integer of latent vector size.
  """
  fake_grid_size = kwargs['fake_grid_size']
  interp_grid_size = kwargs['interp_grid_size']
  colors = kwargs['colors']

  image_shape = list(model.resolution_schedule.final_resolutions)

  fake_batch_size = fake_grid_size**2
  fake_images_shape = [fake_batch_size] + image_shape + [colors]

  interp_batch_size = interp_grid_size**2
  interp_images_shape = [interp_batch_size] + image_shape + [colors]

  # When making prediction, use the ema smoothed generator vars.
  with tf.variable_scope(
      model.gan_model.generator_scope,
      reuse=True,
      custom_getter=make_var_scope_custom_getter_for_ema(model.generator_ema)):
    z_fake = make_latent_vectors(fake_batch_size, **kwargs)
    fake_images = model.gan_model.generator_fn(z_fake)
    fake_images.set_shape(fake_images_shape)

    z_interp = make_interpolated_latent_vectors(interp_grid_size,
                                                interp_grid_size, **kwargs)
    interp_images = model.gan_model.generator_fn(z_interp)
    interp_images.set_shape(interp_images_shape)

  tf.summary.image(
      'fake_images',
      tfgan.eval.eval_utils.image_grid(
          fake_images,
          grid_shape=[fake_grid_size] * 2,
          image_shape=image_shape,
          num_channels=colors),
      max_outputs=1)

  tf.summary.image(
      'interp_images',
      tfgan.eval.eval_utils.image_grid(
          interp_images,
          grid_shape=[interp_grid_size] * 2,
          image_shape=image_shape,
          num_channels=colors),
      max_outputs=1)

  real_grid_size = int(np.sqrt(model.batch_size))
  tf.summary.image(
      'real_images_blend',
      tfgan.eval.eval_utils.image_grid(
          model.gan_model.real_data[:real_grid_size**2],
          grid_shape=(real_grid_size, real_grid_size),
          image_shape=image_shape,
          num_channels=colors),
      max_outputs=1)

  tfgan.eval.add_gan_model_summaries(model.gan_model)
def add_model_summaries ( model , * * kwargs ) : fake_grid_size = kwargs [ 'fake_grid_size' ] interp_grid_size = kwargs [ 'interp_grid_size' ] colors = kwargs [ 'colors' ] image_shape = list ( model . resolution_schedule . final_resolutions ) fake_batch_size = fake_grid_size ** 2 fake_images_shape = [ fake_batch_size ] + image_shape + [ colors ] interp_batch_size = interp_grid_size ** 2 interp_images_shape = [ interp_batch_size ] + image_shape + [ colors ] # When making prediction, use the ema smoothed generator vars. with tf . variable_scope ( model . gan_model . generator_scope , reuse = True , custom_getter = make_var_scope_custom_getter_for_ema ( model . generator_ema ) ) : z_fake = make_latent_vectors ( fake_batch_size , * * kwargs ) fake_images = model . gan_model . generator_fn ( z_fake ) fake_images . set_shape ( fake_images_shape ) z_interp = make_interpolated_latent_vectors ( interp_grid_size , interp_grid_size , * * kwargs ) interp_images = model . gan_model . generator_fn ( z_interp ) interp_images . set_shape ( interp_images_shape ) tf . summary . image ( 'fake_images' , tfgan . eval . eval_utils . image_grid ( fake_images , grid_shape = [ fake_grid_size ] * 2 , image_shape = image_shape , num_channels = colors ) , max_outputs = 1 ) tf . summary . image ( 'interp_images' , tfgan . eval . eval_utils . image_grid ( interp_images , grid_shape = [ interp_grid_size ] * 2 , image_shape = image_shape , num_channels = colors ) , max_outputs = 1 ) real_grid_size = int ( np . sqrt ( model . batch_size ) ) tf . summary . image ( 'real_images_blend' , tfgan . eval . eval_utils . image_grid ( model . gan_model . real_data [ : real_grid_size ** 2 ] , grid_shape = ( real_grid_size , real_grid_size ) , image_shape = image_shape , num_channels = colors ) , max_outputs = 1 ) tfgan . eval . add_gan_model_summaries ( model . gan_model )