(self, note_sequences, assert_same_length=False)
return self.encode_tensors(inputs, lengths, controls)
Encodes a collection of NoteSequences into latent vectors.

    Args:
      note_sequences: A collection of NoteSequence objects to encode.
      assert_same_length: Whether to raise an AssertionError if all of the
        extracted sequences are not the same length.
    Returns:
      The encoded `z`, `mu`, and `sigma` values.
    Raises:
      RuntimeError: If called for a non-conditional model.
      NoExtractedExamplesError: If no examples were extracted.
      MultipleExtractedExamplesError: If multiple examples were extracted.
      AssertionError: If `assert_same_length` is True and any extracted
        sequences differ in length.
Encodes a collection of NoteSequences into latent vectors.
Encodes a collection of NoteSequences into latent vectors .
def encode(self, note_sequences, assert_same_length=False):
    """Encodes a collection of NoteSequences into latent vectors.

    Args:
      note_sequences: A collection of NoteSequence objects to encode.
      assert_same_length: Whether to raise an AssertionError if all of the
        extracted sequences are not the same length.
    Returns:
      The encoded `z`, `mu`, and `sigma` values.
    Raises:
      RuntimeError: If called for a non-conditional model.
      NoExtractedExamplesError: If no examples were extracted.
      MultipleExtractedExamplesError: If multiple examples were extracted.
      AssertionError: If `assert_same_length` is True and any extracted
        sequences differ in length.
    """
    if not self._config.hparams.z_size:
      raise RuntimeError('Cannot encode with a non-conditional model.')

    inputs = []
    controls = []
    lengths = []
    for note_sequence in note_sequences:
      extracted_tensors = self._config.data_converter.to_tensors(note_sequence)
      if not extracted_tensors.inputs:
        raise NoExtractedExamplesError(
            'No examples extracted from NoteSequence: %s' % note_sequence)
      if len(extracted_tensors.inputs) > 1:
        raise MultipleExtractedExamplesError(
            'Multiple (%d) examples extracted from NoteSequence: %s' %
            (len(extracted_tensors.inputs), note_sequence))
      inputs.append(extracted_tensors.inputs[0])
      controls.append(extracted_tensors.controls[0])
      lengths.append(extracted_tensors.lengths[0])
      if assert_same_length and len(inputs[0]) != len(inputs[-1]):
        raise AssertionError(
            'Sequences 0 and %d have different lengths: %d vs %d' %
            (len(inputs) - 1, len(inputs[0]), len(inputs[-1])))
    return self.encode_tensors(inputs, lengths, controls)
def encode ( self , note_sequences , assert_same_length = False ) : if not self . _config . hparams . z_size : raise RuntimeError ( 'Cannot encode with a non-conditional model.' ) inputs = [ ] controls = [ ] lengths = [ ] for note_sequence in note_sequences : extracted_tensors = self . _config . data_converter . to_tensors ( note_sequence ) if not extracted_tensors . inputs : raise NoExtractedExamplesError ( 'No examples extracted from NoteSequence: %s' % note_sequence ) if len ( extracted_tensors . inputs ) > 1 : raise MultipleExtractedExamplesError ( 'Multiple (%d) examples extracted from NoteSequence: %s' % ( len ( extracted_tensors . inputs ) , note_sequence ) ) inputs . append ( extracted_tensors . inputs [ 0 ] ) controls . append ( extracted_tensors . controls [ 0 ] ) lengths . append ( extracted_tensors . lengths [ 0 ] ) if assert_same_length and len ( inputs [ 0 ] ) != len ( inputs [ - 1 ] ) : raise AssertionError ( 'Sequences 0 and %d have different lengths: %d vs %d' % ( len ( inputs ) - 1 , len ( inputs [ 0 ] ) , len ( inputs [ - 1 ] ) ) ) return self . encode_tensors ( inputs , lengths , controls )