(sess, gan, z_sample, avg_info, dist_p1, dist_p2, fake_images,
                outdir, options)
return mean_eval_info
Evaluate GILBO on new data from the generative model.

  Args:
    sess: tf.Session.
    gan: GAN object.
    z_sample: Tensor sampling from the prior.
    avg_info: Tensor that computes the per-batch GILBO.
    dist_p1: Tensor for the first parameter of the distribution
             (e.g., concentration1 for a Beta distribution).
    dist_p2: Tensor for the second parameter of the distribution
             (e.g., concentration2 for a Beta distribution).
    fake_images: Tensor of images sampled from the GAN.
    outdir: Output directory. A pickle file will be written there.
    options: Options dictionary.

  Returns:
    The mean GILBO on the evaluation set. Also writes a pickle file saving
    distribution parameters and generated images for later analysis.
Evaluate GILBO on new data from the generative model.
Evaluate GILBO on new data from the generative model .
def _eval_gilbo(sess, gan, z_sample, avg_info, dist_p1, dist_p2, fake_images,
                outdir, options):
  """Evaluate GILBO on new data from the generative model.

  Args:
    sess: tf.Session.
    gan: GAN object.
    z_sample: Tensor sampling from the prior.
    avg_info: Tensor that computes the per-batch GILBO.
    dist_p1: Tensor for the first parameter of the distribution
             (e.g., concentration1 for a Beta distribution).
    dist_p2: Tensor for the second parameter of the distribution
             (e.g., concentration2 for a Beta distribution).
    fake_images: Tensor of images sampled from the GAN.
    outdir: Output directory. A pickle file will be written there.
    options: Options dictionary.

  Returns:
    The mean GILBO on the evaluation set. Also writes a pickle file saving
    distribution parameters and generated images for later analysis.
  """
  eval_steps = options.get("gilbo_eval_steps", 10000)
  z_infos = np.zeros(eval_steps, np.float32)
  z_dist_p1s, z_dist_p2s, z_fake_images = [], [], []
  mean_eval_info = 0
  for i in range(eval_steps):
    samp = sess.run(z_sample)
    if i * gan.batch_size < 1000:
      # Save the first 1000 distribution parameters and generated images for
      # separate data processing.
      z_infos[i], z_dist_p1, z_dist_p2, images = sess.run(
          [avg_info, dist_p1, dist_p2, fake_images], feed_dict={gan.z: samp})
      z_dist_p1s.append(z_dist_p1)
      z_dist_p2s.append(z_dist_p2)
      z_fake_images.append(images)
    else:
      z_infos[i] = sess.run(avg_info, feed_dict={gan.z: samp})

    if i % (eval_steps // 10) == 0:
      tf.logging.info("eval step:%d gilbo:%3.1f" % (i, z_infos[i]))

  if eval_steps:
    mean_eval_info = np.mean(np.nan_to_num(z_infos))
    eval_dists = dict(
        dist_p1=np.array(z_dist_p1s).reshape([-1, 64]),
        dist_p2=np.array(z_dist_p2s).reshape([-1, 64]),
        images=np.array(z_fake_images).reshape(
            [-1] + list(z_fake_images[0].shape[1:])))
    with tf.gfile.Open(os.path.join(outdir, "eval_dists.p"), "w") as f:
      pickle.dump(eval_dists, f)
    tf.logging.info("eval gilbo:%3.1f" % mean_eval_info)

  return mean_eval_info
def _eval_gilbo ( sess , gan , z_sample , avg_info , dist_p1 , dist_p2 , fake_images , outdir , options ) : eval_steps = options . get ( "gilbo_eval_steps" , 10000 ) z_infos = np . zeros ( eval_steps , np . float32 ) z_dist_p1s , z_dist_p2s , z_fake_images = [ ] , [ ] , [ ] mean_eval_info = 0 for i in range ( eval_steps ) : samp = sess . run ( z_sample ) if i * gan . batch_size < 1000 : # Save the first 1000 distribution parameters and generated images for # separate data processing. z_infos [ i ] , z_dist_p1 , z_dist_p2 , images = sess . run ( [ avg_info , dist_p1 , dist_p2 , fake_images ] , feed_dict = { gan . z : samp } ) z_dist_p1s . append ( z_dist_p1 ) z_dist_p2s . append ( z_dist_p2 ) z_fake_images . append ( images ) else : z_infos [ i ] = sess . run ( avg_info , feed_dict = { gan . z : samp } ) if i % ( eval_steps // 10 ) == 0 : tf . logging . info ( "eval step:%d gilbo:%3.1f" % ( i , z_infos [ i ] ) ) if eval_steps : mean_eval_info = np . mean ( np . nan_to_num ( z_infos ) ) eval_dists = dict ( dist_p1 = np . array ( z_dist_p1s ) . reshape ( [ - 1 , 64 ] ) , dist_p2 = np . array ( z_dist_p2s ) . reshape ( [ - 1 , 64 ] ) , images = np . array ( z_fake_images ) . reshape ( [ - 1 ] + list ( z_fake_images [ 0 ] . shape [ 1 : ] ) ) ) with tf . gfile . Open ( os . path . join ( outdir , "eval_dists.p" ) , "w" ) as f : pickle . dump ( eval_dists , f ) tf . logging . info ( "eval gilbo:%3.1f" % mean_eval_info ) return mean_eval_info