data.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:magenta 作者: tensorflow 项目源码 文件源码
def sequence_to_pianoroll_op(sequence_tensor, hparams):
  """Transforms a serialized NoteSequence to a pianoroll."""
  def sequence_to_pianoroll_fn(sequence_tensor):
    sequence = preprocess_sequence(sequence_tensor)
    return sequence_to_pianoroll(
        sequence,
        frames_per_second=hparams_frames_per_second(hparams),
        min_pitch=constants.MIN_MIDI_PITCH,
        max_pitch=constants.MAX_MIDI_PITCH,
        min_frame_occupancy_for_label=hparams.min_frame_occupancy_for_label,
        onset_mode=hparams.onset_mode, onset_length_ms=hparams.onset_length,
        onset_delay_ms=hparams.onset_delay)

  res, weighted_res, onsets = tf.py_func(
      sequence_to_pianoroll_fn, [sequence_tensor],
      [tf.float32, tf.float32, tf.float32],
      name='sequence_to_pianoroll_op')
  res.set_shape([None, constants.MIDI_PITCHES])
  weighted_res.set_shape([None, constants.MIDI_PITCHES])
  onsets.set_shape([None, constants.MIDI_PITCHES])

  return res, weighted_res, onsets
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号