(self, samples, controls=None)
return output_sequences
Converts model samples to a list of `NoteSequence`s.
Converts model samples to a list of `NoteSequence`s.
Converts model samples to a list of NoteSequence s .
def from_tensors(self, samples, controls=None):
    """Converts model samples to a list of `NoteSequence`s."""
    output_sequences = []
    for i, sample in enumerate(samples):
      s = np.argmax(sample, axis=-1)
      if self.end_token is not None and self.end_token in s.tolist():
        end_index = s.tolist().index(self.end_token)
      else:
        end_index = len(s)
      s = s[:end_index]
      event_list = self._event_list_fn()
      for e in s:
        assert e != self.end_token
        event_list.append(self._legacy_encoder_decoder.decode_event(e))
      if self._steps_per_quarter:
        qpm = note_seq.DEFAULT_QUARTERS_PER_MINUTE
        seconds_per_step = 60.0 / (self._steps_per_quarter * qpm)
        sequence = event_list.to_sequence(velocity=OUTPUT_VELOCITY, qpm=qpm)
      else:
        seconds_per_step = 1.0 / self._steps_per_second
        sequence = event_list.to_sequence(velocity=OUTPUT_VELOCITY)
      if self._chord_encoding and controls is not None:
        chords = [self._chord_encoding.decode_event(e)
                  for e in np.argmax(controls[i][:, :-12], axis=-1)[:end_index]]
        chord_times = [step * seconds_per_step for step in event_list.steps]
        chords_lib.add_chords_to_sequence(sequence, chords, chord_times)
      if self._condition_on_key and controls is not None:
        keys = np.argmax(controls[i][:, -12:], axis=-1)[:end_index]
        key_times = [step * seconds_per_step for step in event_list.steps]
        chords_lib.add_keys_to_sequence(sequence, keys, key_times)
      output_sequences.append(sequence)
    return output_sequences
def from_tensors ( self , samples , controls = None ) : output_sequences = [ ] for i , sample in enumerate ( samples ) : s = np . argmax ( sample , axis = - 1 ) if self . end_token is not None and self . end_token in s . tolist ( ) : end_index = s . tolist ( ) . index ( self . end_token ) else : end_index = len ( s ) s = s [ : end_index ] event_list = self . _event_list_fn ( ) for e in s : assert e != self . end_token event_list . append ( self . _legacy_encoder_decoder . decode_event ( e ) ) if self . _steps_per_quarter : qpm = note_seq . DEFAULT_QUARTERS_PER_MINUTE seconds_per_step = 60.0 / ( self . _steps_per_quarter * qpm ) sequence = event_list . to_sequence ( velocity = OUTPUT_VELOCITY , qpm = qpm ) else : seconds_per_step = 1.0 / self . _steps_per_second sequence = event_list . to_sequence ( velocity = OUTPUT_VELOCITY ) if self . _chord_encoding and controls is not None : chords = [ self . _chord_encoding . decode_event ( e ) for e in np . argmax ( controls [ i ] [ : , : - 12 ] , axis = - 1 ) [ : end_index ] ] chord_times = [ step * seconds_per_step for step in event_list . steps ] chords_lib . add_chords_to_sequence ( sequence , chords , chord_times ) if self . _condition_on_key and controls is not None : keys = np . argmax ( controls [ i ] [ : , - 12 : ] , axis = - 1 ) [ : end_index ] key_times = [ step * seconds_per_step for step in event_list . steps ] chords_lib . add_keys_to_sequence ( sequence , keys , key_times ) output_sequences . append ( sequence ) return output_sequences