(sess, generator, num_batches, batch_size)
return fake_images
Returns a generated data set as a NumPy array.
Returns a generated data set as a NumPy array.
Returns a generated data set as a NumPy array .
def sample_fake_dataset(sess, generator, num_batches, batch_size):
  """Returns a generated data set as a NumPy array."""
  logging.info("Generating a fake data set.")
  for i in tqdm(range(num_batches)):
    x = sess.run(generator)
    # If NaNs were generated, ignore this checkpoint and assign a very high
    # FID score which we handle specially later.
    if np.isnan(x).any():
      logging.error("Detected NaN in fake_images! Returning NaN.")
      raise NanFoundError("Detected NaN in fake images.")
    if i == 0:
      fake_images = np.zeros([num_batches * batch_size, *x.shape[1:]], dtype=x.dtype)
    fake_images[i * batch_size: (i + 1) * batch_size] = x
  fake_images *= 255.0
  # Convert 1-channel datasets (like MNIST) to 3 channels.
  if fake_images.shape[3] == 1:
    fake_images = np.tile(fake_images, [1, 1, 1, 3])
  logging.info("Done sampling a generated data set.")
  return fake_images
def sample_fake_dataset ( sess , generator , num_batches , batch_size ) : logging . info ( "Generating a fake data set." ) for i in tqdm ( range ( num_batches ) ) : x = sess . run ( generator ) # If NaNs were generated, ignore this checkpoint and assign a very high # FID score which we handle specially later. if np . isnan ( x ) . any ( ) : logging . error ( "Detected NaN in fake_images! Returning NaN." ) raise NanFoundError ( "Detected NaN in fake images." ) if i == 0 : fake_images = np . zeros ( [ num_batches * batch_size , * x . shape [ 1 : ] ] , dtype = x . dtype ) fake_images [ i * batch_size : ( i + 1 ) * batch_size ] = x fake_images *= 255.0 # Convert 1-channel datasets (like MNIST) to 3 channels. if fake_images . shape [ 3 ] == 1 : fake_images = np . tile ( fake_images , [ 1 , 1 , 1 , 3 ] ) logging . info ( "Done sampling a generated data set." ) return fake_images