(dataset,
                    num_examples,
                    split=None,
                    failure_on_insufficient_examples=True)
return real_images
Get num_examples images from the given dataset/split.

  Args:
    dataset: `ImageDataset` object.
    num_examples: Number of images to read.
    split: Split of the dataset to use. If None will use the default split for
      eval defined by the dataset.
    failure_on_insufficient_examples: If True raise an exception if the
      dataset/split does not images. Otherwise will log to error and return
      fewer images.

  Returns:
    4-D NumPy array with images with values in [0, 256].

  Raises:
    ValueError: If the dataset/split does not of the number of requested number
        requested images and `failure_on_insufficient_examples` is True.
Get num_examples images from the given dataset/split.
Get num_examples images from the given dataset / split .
def get_real_images(dataset,
                    num_examples,
                    split=None,
                    failure_on_insufficient_examples=True):
  """Get num_examples images from the given dataset/split.

  Args:
    dataset: `ImageDataset` object.
    num_examples: Number of images to read.
    split: Split of the dataset to use. If None will use the default split for
      eval defined by the dataset.
    failure_on_insufficient_examples: If True raise an exception if the
      dataset/split does not images. Otherwise will log to error and return
      fewer images.

  Returns:
    4-D NumPy array with images with values in [0, 256].

  Raises:
    ValueError: If the dataset/split does not of the number of requested number
        requested images and `failure_on_insufficient_examples` is True.
  """
  logging.info("Start loading real data.")
  with tf.Graph().as_default():
    ds = dataset.eval_input_fn(split=split)
    # Get real images from the dataset. In the case of a 1-channel
    # dataset (like MNIST) convert it to 3 channels.
    next_batch = ds.make_one_shot_iterator().get_next()[0]
    shape = [num_examples] + next_batch.shape.as_list()
    is_single_channel = shape[-1] == 1
    if is_single_channel:
      shape[-1] = 3
    real_images = np.empty(shape, dtype=np.float32)
    with tf.Session() as sess:
      for i in range(num_examples):
        try:
          b = sess.run(next_batch)
          b *= 255.0
          if is_single_channel:
            b = np.tile(b, [1, 1, 3])
          real_images[i] = b
        except tf.errors.OutOfRangeError:
          logging.error("Reached the end of dataset. Read: %d samples.", i)
          break

  if real_images.shape[0] != num_examples:
    if failure_on_insufficient_examples:
      raise ValueError("Not enough examples in the dataset %s: %d / %d" %
                       (dataset, real_images.shape[0], num_examples))
    else:
      logging.error("Not enough examples in the dataset %s: %d / %d", dataset,
                    real_images.shape[0], num_examples)

  logging.info("Done loading real data.")
  return real_images
def get_real_images ( dataset , num_examples , split = None , failure_on_insufficient_examples = True ) : logging . info ( "Start loading real data." ) with tf . Graph ( ) . as_default ( ) : ds = dataset . eval_input_fn ( split = split ) # Get real images from the dataset. In the case of a 1-channel # dataset (like MNIST) convert it to 3 channels. next_batch = ds . make_one_shot_iterator ( ) . get_next ( ) [ 0 ] shape = [ num_examples ] + next_batch . shape . as_list ( ) is_single_channel = shape [ - 1 ] == 1 if is_single_channel : shape [ - 1 ] = 3 real_images = np . empty ( shape , dtype = np . float32 ) with tf . Session ( ) as sess : for i in range ( num_examples ) : try : b = sess . run ( next_batch ) b *= 255.0 if is_single_channel : b = np . tile ( b , [ 1 , 1 , 3 ] ) real_images [ i ] = b except tf . errors . OutOfRangeError : logging . error ( "Reached the end of dataset. Read: %d samples." , i ) break if real_images . shape [ 0 ] != num_examples : if failure_on_insufficient_examples : raise ValueError ( "Not enough examples in the dataset %s: %d / %d" % ( dataset , real_images . shape [ 0 ] , num_examples ) ) else : logging . error ( "Not enough examples in the dataset %s: %d / %d" , dataset , real_images . shape [ 0 ] , num_examples ) logging . info ( "Done loading real data." ) return real_images