(examples_path, tfds_name, data_converter,
                   file_reader=tf.python_io.tf_record_iterator)
return num_examples
Counts the number of examples produced by the converter from files.
Counts the number of examples produced by the converter from files.
Counts the number of examples produced by the converter from files .
def count_examples(examples_path, tfds_name, data_converter,
                   file_reader=tf.python_io.tf_record_iterator):
  """Counts the number of examples produced by the converter from files."""
  def _file_generator():
    filenames = tf.gfile.Glob(examples_path)
    for f in filenames:
      tf.logging.info('Counting examples in %s.', f)
      reader = file_reader(f)
      for item_str in reader:
        yield data_converter.str_to_item_fn(item_str)

  def _tfds_generator():
    ds = tfds.as_numpy(
        tfds.load(tfds_name, split=tfds.Split.VALIDATION, try_gcs=True))
    # TODO(adarob): Generalize to other data types if needed.
    for ex in ds:
      yield note_seq.midi_to_note_sequence(ex['midi'])

  num_examples = 0

  generator = _tfds_generator if tfds_name else _file_generator
  for item in generator():
    tensors = data_converter.to_tensors(item)
    num_examples += len(tensors.inputs)
  tf.logging.info('Total examples: %d', num_examples)
  return num_examples
def count_examples ( examples_path , tfds_name , data_converter , file_reader = tf . python_io . tf_record_iterator ) : def _file_generator ( ) : filenames = tf . gfile . Glob ( examples_path ) for f in filenames : tf . logging . info ( 'Counting examples in %s.' , f ) reader = file_reader ( f ) for item_str in reader : yield data_converter . str_to_item_fn ( item_str ) def _tfds_generator ( ) : ds = tfds . as_numpy ( tfds . load ( tfds_name , split = tfds . Split . VALIDATION , try_gcs = True ) ) # TODO(adarob): Generalize to other data types if needed. for ex in ds : yield note_seq . midi_to_note_sequence ( ex [ 'midi' ] ) num_examples = 0 generator = _tfds_generator if tfds_name else _file_generator for item in generator ( ) : tensors = data_converter . to_tensors ( item ) num_examples += len ( tensors . inputs ) tf . logging . info ( 'Total examples: %d' , num_examples ) return num_examples