(self, input_tensors, lengths, control_tensors=None)
return tuple(np.vstack(v)[:n] for v in zip(*outputs))
Encodes a collection of input tensors into latent vectors.

    Args:
      input_tensors: Collection of input tensors to encode.
      lengths: Collection of lengths of input tensors.
      control_tensors: Collection of control tensors to encode.
    Returns:
      The encoded `z`, `mu`, and `sigma` values.
    Raises:
       RuntimeError: If called for a non-conditional model.
Encodes a collection of input tensors into latent vectors.
Encodes a collection of input tensors into latent vectors .
def encode_tensors(self, input_tensors, lengths, control_tensors=None):
    """Encodes a collection of input tensors into latent vectors.

    Args:
      input_tensors: Collection of input tensors to encode.
      lengths: Collection of lengths of input tensors.
      control_tensors: Collection of control tensors to encode.
    Returns:
      The encoded `z`, `mu`, and `sigma` values.
    Raises:
       RuntimeError: If called for a non-conditional model.
    """
    if not self._config.hparams.z_size:
      raise RuntimeError('Cannot encode with a non-conditional model.')

    n = len(input_tensors)
    input_depth = self._config.data_converter.input_depth
    batch_size = self._config.hparams.batch_size

    batch_pad_amt = -n % batch_size
    if batch_pad_amt > 0:
      input_tensors += [np.zeros([0, input_depth])] * batch_pad_amt
    length_array = np.array(lengths, np.int32)
    length_array = np.pad(
        length_array,
        [(0, batch_pad_amt)] + [(0, 0)] * (length_array.ndim - 1),
        'constant')

    max_length = max([len(t) for t in input_tensors])
    inputs_array = np.zeros(
        [len(input_tensors), max_length, input_depth])
    for i, t in enumerate(input_tensors):
      inputs_array[i, :len(t)] = t

    control_depth = self._config.data_converter.control_depth
    controls_array = np.zeros(
        [len(input_tensors), max_length, control_depth])
    if control_tensors is not None:
      control_tensors += [np.zeros([0, control_depth])] * batch_pad_amt
      for i, t in enumerate(control_tensors):
        controls_array[i, :len(t)] = t

    outputs = []
    for i in range(len(inputs_array) // batch_size):
      batch_begin = i * batch_size
      batch_end = (i+1) * batch_size
      feed_dict = {self._inputs: inputs_array[batch_begin:batch_end],
                   self._controls: controls_array[batch_begin:batch_end],
                   self._inputs_length: length_array[batch_begin:batch_end]}
      outputs.append(
          self._sess.run([self._z, self._mu, self._sigma], feed_dict))
    assert outputs
    return tuple(np.vstack(v)[:n] for v in zip(*outputs))
def encode_tensors ( self , input_tensors , lengths , control_tensors = None ) : if not self . _config . hparams . z_size : raise RuntimeError ( 'Cannot encode with a non-conditional model.' ) n = len ( input_tensors ) input_depth = self . _config . data_converter . input_depth batch_size = self . _config . hparams . batch_size batch_pad_amt = - n % batch_size if batch_pad_amt > 0 : input_tensors += [ np . zeros ( [ 0 , input_depth ] ) ] * batch_pad_amt length_array = np . array ( lengths , np . int32 ) length_array = np . pad ( length_array , [ ( 0 , batch_pad_amt ) ] + [ ( 0 , 0 ) ] * ( length_array . ndim - 1 ) , 'constant' ) max_length = max ( [ len ( t ) for t in input_tensors ] ) inputs_array = np . zeros ( [ len ( input_tensors ) , max_length , input_depth ] ) for i , t in enumerate ( input_tensors ) : inputs_array [ i , : len ( t ) ] = t control_depth = self . _config . data_converter . control_depth controls_array = np . zeros ( [ len ( input_tensors ) , max_length , control_depth ] ) if control_tensors is not None : control_tensors += [ np . zeros ( [ 0 , control_depth ] ) ] * batch_pad_amt for i , t in enumerate ( control_tensors ) : controls_array [ i , : len ( t ) ] = t outputs = [ ] for i in range ( len ( inputs_array ) // batch_size ) : batch_begin = i * batch_size batch_end = ( i + 1 ) * batch_size feed_dict = { self . _inputs : inputs_array [ batch_begin : batch_end ] , self . _controls : controls_array [ batch_begin : batch_end ] , self . _inputs_length : length_array [ batch_begin : batch_end ] } outputs . append ( self . _sess . run ( [ self . _z , self . _mu , self . _sigma ] , feed_dict ) ) assert outputs return tuple ( np . vstack ( v ) [ : n ] for v in zip ( * outputs ) )