(gan, z_sample, z_pred_dist, outdir, step)
Save a histogram for each z dimension as an png in outdir.
Save a histogram for each z dimension as an png in outdir.
Save a histogram for each z dimension as an png in outdir .
def _save_z_histograms(gan, z_sample, z_pred_dist, outdir, step):
  """Save a histogram for each z dimension as an png in outdir."""
  fig, axs = plt.subplots(8, 8, figsize=(15, 10))

  pk = 0
  bins = np.linspace(-1, 1, 70)

  samp = z_sample.eval()
  z_pred_samp = z_pred_dist.sample(10000).eval({gan.z: samp})

  try:
    for j in range(64):
      axs.flat[j].hist(z_pred_samp[:, pk, j], bins, histtype="stepfilled",
                       normed=True)
      axs.flat[j].vlines(samp[pk, j], 0, 1.0, linestyle="dashed")
    plt.tight_layout()
    filename = os.path.join(outdir, "z_hist_%03d.png" % step)
    tf.logging.info("Saving z histogram: %s" % filename)
    with tf.gfile.Open(filename, "w") as f:
      fig.savefig(f, dpi="figure")
  except Exception as e:  # pylint: disable=broad-except
    tf.logging.info("Caught %r while rendering chart. Ignoring.\n%s\n"
                    % (type(e), str(e)))
def _save_z_histograms ( gan , z_sample , z_pred_dist , outdir , step ) : fig , axs = plt . subplots ( 8 , 8 , figsize = ( 15 , 10 ) ) pk = 0 bins = np . linspace ( - 1 , 1 , 70 ) samp = z_sample . eval ( ) z_pred_samp = z_pred_dist . sample ( 10000 ) . eval ( { gan . z : samp } ) try : for j in range ( 64 ) : axs . flat [ j ] . hist ( z_pred_samp [ : , pk , j ] , bins , histtype = "stepfilled" , normed = True ) axs . flat [ j ] . vlines ( samp [ pk , j ] , 0 , 1.0 , linestyle = "dashed" ) plt . tight_layout ( ) filename = os . path . join ( outdir , "z_hist_%03d.png" % step ) tf . logging . info ( "Saving z histogram: %s" % filename ) with tf . gfile . Open ( filename , "w" ) as f : fig . savefig ( f , dpi = "figure" ) except Exception as e : # pylint: disable=broad-except tf . logging . info ( "Caught %r while rendering chart. Ignoring.\n%s\n" % ( type ( e ) , str ( e ) ) )