tensorflow_probability/examples/vq_vae.py
def save_imgs(x, fname):
  """Helper method to save a grid of images to a PNG file.

  Args:
    x: A numpy array of shape [n_images, height, width].
    fname: The filename to write to (including extension).
  """
  n = x.shape[0]
  fig = figure.Figure(figsize=(n, 1), frameon=False)
  canvas = backend_agg.FigureCanvasAgg(fig)
  for i in range(n):
    ax = fig.add_subplot(1, n, i+1)
    ax.imshow(x[i].squeeze(),
              interpolation="none",
              cmap=cm.get_cmap("binary"))
    ax.axis("off")
  canvas.print_figure(fname, format="png")
  print("saved %s" % fname)
def save_imgs(x, fname):
  n = x.shape[0]
  fig = figure.Figure(figsize=(n, 1), frameon=False)
  canvas = backend_agg.FigureCanvasAgg(fig)
  for i in range(n):
    ax = fig.add_subplot(1, n, i+1)
    ax.imshow(x[i].squeeze(),
              interpolation="none",
              cmap=cm.get_cmap("binary"))
    ax.axis("off")
  canvas.print_figure(fname, format="png")
  print("saved %s" % fname)
def save_imgs ( x , fname ) : n = x . shape [ 0 ] fig = figure . Figure ( figsize = ( n , 1 ) , frameon = False ) canvas = backend_agg . FigureCanvasAgg ( fig ) for i in range ( n ) : ax = fig . add_subplot ( 1 , n , i + 1 ) ax . imshow ( x [ i ] . squeeze ( ) , interpolation = "none" , cmap = cm . get_cmap ( "binary" ) ) ax . axis ( "off" ) canvas . print_figure ( fname , format = "png" ) print ( "saved %s" % fname )
Helper method to save a grid of images to a PNG file.

  Args:
    x: A numpy array of shape [n_images, height, width].
    fname: The filename to write to (including extension).
Helper method to save a grid of images to a PNG file .