(examples, is_training, shuffle_examples,
                  skip_n_initial_records, hparams)
return input_dataset
Returns a tf.data.Dataset from TFRecord files.

  Args:
    examples: A string path to a TFRecord file of examples, a python list of
      serialized examples, or a Tensor placeholder for serialized examples.
    is_training: Whether this is a training run.
    shuffle_examples: Whether examples should be shuffled.
    skip_n_initial_records: Skip this many records at first.
    hparams: HParams object specifying hyperparameters.

  Returns:
    A tf.data.Dataset.
Returns a tf.data.Dataset from TFRecord files.
Returns a tf . data . Dataset from TFRecord files .
def read_examples(examples, is_training, shuffle_examples,
                  skip_n_initial_records, hparams):
  """Returns a tf.data.Dataset from TFRecord files.

  Args:
    examples: A string path to a TFRecord file of examples, a python list of
      serialized examples, or a Tensor placeholder for serialized examples.
    is_training: Whether this is a training run.
    shuffle_examples: Whether examples should be shuffled.
    skip_n_initial_records: Skip this many records at first.
    hparams: HParams object specifying hyperparameters.

  Returns:
    A tf.data.Dataset.
  """
  if is_training and not shuffle_examples:
    raise ValueError('shuffle_examples must be True if is_training is True')

  if isinstance(examples, str):
    # Read examples from a TFRecord file containing serialized NoteSequence
    # and audio.
    sharded_filenames = generate_sharded_filenames(examples)
    if len(sharded_filenames) == 1:
      # Could be a glob pattern.
      filenames = tf.data.Dataset.list_files(
          generate_sharded_filenames(examples), shuffle=shuffle_examples)
    else:
      # If we've already expanded the list of sharded filenames, don't send to
      # Dataset.list_files because that will attempt to execute a potentially
      # slow (especially for network filesystems) glob expansion on each entry
      # in the already expanded list.
      if shuffle_examples:
        np.random.shuffle(sharded_filenames)
      filenames = tf.data.Dataset.from_tensor_slices(sharded_filenames)

    if shuffle_examples:
      input_dataset = filenames.apply(
          tf.data.experimental.parallel_interleave(
              tf.data.TFRecordDataset, sloppy=True, cycle_length=8))
    else:
      input_dataset = tf.data.TFRecordDataset(filenames)
  else:
    input_dataset = tf.data.Dataset.from_tensor_slices(examples)

  if shuffle_examples:
    input_dataset = input_dataset.shuffle(hparams.shuffle_buffer_size)
  if is_training:
    input_dataset = input_dataset.repeat()
  if skip_n_initial_records:
    input_dataset = input_dataset.skip(skip_n_initial_records)

  return input_dataset
def read_examples ( examples , is_training , shuffle_examples , skip_n_initial_records , hparams ) : if is_training and not shuffle_examples : raise ValueError ( 'shuffle_examples must be True if is_training is True' ) if isinstance ( examples , str ) : # Read examples from a TFRecord file containing serialized NoteSequence # and audio. sharded_filenames = generate_sharded_filenames ( examples ) if len ( sharded_filenames ) == 1 : # Could be a glob pattern. filenames = tf . data . Dataset . list_files ( generate_sharded_filenames ( examples ) , shuffle = shuffle_examples ) else : # If we've already expanded the list of sharded filenames, don't send to # Dataset.list_files because that will attempt to execute a potentially # slow (especially for network filesystems) glob expansion on each entry # in the already expanded list. if shuffle_examples : np . random . shuffle ( sharded_filenames ) filenames = tf . data . Dataset . from_tensor_slices ( sharded_filenames ) if shuffle_examples : input_dataset = filenames . apply ( tf . data . experimental . parallel_interleave ( tf . data . TFRecordDataset , sloppy = True , cycle_length = 8 ) ) else : input_dataset = tf . data . TFRecordDataset ( filenames ) else : input_dataset = tf . data . Dataset . from_tensor_slices ( examples ) if shuffle_examples : input_dataset = input_dataset . shuffle ( hparams . shuffle_buffer_size ) if is_training : input_dataset = input_dataset . repeat ( ) if skip_n_initial_records : input_dataset = input_dataset . skip ( skip_n_initial_records ) return input_dataset