(example_proto)
return input_tensors
Process an already preprocessed Example proto into input tensors.
Process an already preprocessed Example proto into input tensors.
Process an already preprocessed Example proto into input tensors .
def parse_preprocessed_example(example_proto):
  """Process an already preprocessed Example proto into input tensors."""
  features = {
      'spec': tf.VarLenFeature(dtype=tf.float32),
      'spectrogram_hash': tf.FixedLenFeature(shape=(), dtype=tf.int64),
      'labels': tf.VarLenFeature(dtype=tf.float32),
      'label_weights': tf.VarLenFeature(dtype=tf.float32),
      'length': tf.FixedLenFeature(shape=(), dtype=tf.int64),
      'onsets': tf.VarLenFeature(dtype=tf.float32),
      'offsets': tf.VarLenFeature(dtype=tf.float32),
      'velocities': tf.VarLenFeature(dtype=tf.float32),
      'sequence_id': tf.FixedLenFeature(shape=(), dtype=tf.string),
      'note_sequence': tf.FixedLenFeature(shape=(), dtype=tf.string),
  }
  record = tf.parse_single_example(example_proto, features)
  input_tensors = InputTensors(
      spec=tf.sparse.to_dense(record['spec']),
      spectrogram_hash=record['spectrogram_hash'],
      labels=tf.sparse.to_dense(record['labels']),
      label_weights=tf.sparse.to_dense(record['label_weights']),
      length=record['length'],
      onsets=tf.sparse.to_dense(record['onsets']),
      offsets=tf.sparse.to_dense(record['offsets']),
      velocities=tf.sparse.to_dense(record['velocities']),
      sequence_id=record['sequence_id'],
      note_sequence=record['note_sequence'])
  return input_tensors
def parse_preprocessed_example ( example_proto ) : features = { 'spec' : tf . VarLenFeature ( dtype = tf . float32 ) , 'spectrogram_hash' : tf . FixedLenFeature ( shape = ( ) , dtype = tf . int64 ) , 'labels' : tf . VarLenFeature ( dtype = tf . float32 ) , 'label_weights' : tf . VarLenFeature ( dtype = tf . float32 ) , 'length' : tf . FixedLenFeature ( shape = ( ) , dtype = tf . int64 ) , 'onsets' : tf . VarLenFeature ( dtype = tf . float32 ) , 'offsets' : tf . VarLenFeature ( dtype = tf . float32 ) , 'velocities' : tf . VarLenFeature ( dtype = tf . float32 ) , 'sequence_id' : tf . FixedLenFeature ( shape = ( ) , dtype = tf . string ) , 'note_sequence' : tf . FixedLenFeature ( shape = ( ) , dtype = tf . string ) , } record = tf . parse_single_example ( example_proto , features ) input_tensors = InputTensors ( spec = tf . sparse . to_dense ( record [ 'spec' ] ) , spectrogram_hash = record [ 'spectrogram_hash' ] , labels = tf . sparse . to_dense ( record [ 'labels' ] ) , label_weights = tf . sparse . to_dense ( record [ 'label_weights' ] ) , length = record [ 'length' ] , onsets = tf . sparse . to_dense ( record [ 'onsets' ] ) , offsets = tf . sparse . to_dense ( record [ 'offsets' ] ) , velocities = tf . sparse . to_dense ( record [ 'velocities' ] ) , sequence_id = record [ 'sequence_id' ] , note_sequence = record [ 'note_sequence' ] ) return input_tensors