(self, sequence, sequence_length, control_sequence=None)
return ds.MultivariateNormalDiag(loc=mu, scale_diag=sigma)
Encodes input sequences into a MultivariateNormalDiag distribution.

    Args:
      sequence: A Tensor with shape `[num_sequences, max_length, input_depth]`
          containing the sequences to encode.
      sequence_length: The length of each sequence in the `sequence` Tensor.
      control_sequence: (Optional) A Tensor with shape
          `[num_sequences, max_length, control_depth]` containing control
          sequences on which to condition. These will be concatenated depthwise
          to the input sequences.

    Returns:
      A tfp.distributions.MultivariateNormalDiag representing the posterior
      distribution for each sequence.
Encodes input sequences into a MultivariateNormalDiag distribution.
Encodes input sequences into a MultivariateNormalDiag distribution .
def encode(self, sequence, sequence_length, control_sequence=None):
    """Encodes input sequences into a MultivariateNormalDiag distribution.

    Args:
      sequence: A Tensor with shape `[num_sequences, max_length, input_depth]`
          containing the sequences to encode.
      sequence_length: The length of each sequence in the `sequence` Tensor.
      control_sequence: (Optional) A Tensor with shape
          `[num_sequences, max_length, control_depth]` containing control
          sequences on which to condition. These will be concatenated depthwise
          to the input sequences.

    Returns:
      A tfp.distributions.MultivariateNormalDiag representing the posterior
      distribution for each sequence.
    """
    hparams = self.hparams
    z_size = hparams.z_size

    sequence = tf.to_float(sequence)
    if control_sequence is not None:
      control_sequence = tf.to_float(control_sequence)
      sequence = tf.concat([sequence, control_sequence], axis=-1)
    encoder_output = self.encoder.encode(sequence, sequence_length)

    mu = tf.layers.dense(
        encoder_output,
        z_size,
        name='encoder/mu',
        kernel_initializer=tf.random_normal_initializer(stddev=0.001))
    sigma = tf.layers.dense(
        encoder_output,
        z_size,
        activation=tf.nn.softplus,
        name='encoder/sigma',
        kernel_initializer=tf.random_normal_initializer(stddev=0.001))

    return ds.MultivariateNormalDiag(loc=mu, scale_diag=sigma)
def encode ( self , sequence , sequence_length , control_sequence = None ) : hparams = self . hparams z_size = hparams . z_size sequence = tf . to_float ( sequence ) if control_sequence is not None : control_sequence = tf . to_float ( control_sequence ) sequence = tf . concat ( [ sequence , control_sequence ] , axis = - 1 ) encoder_output = self . encoder . encode ( sequence , sequence_length ) mu = tf . layers . dense ( encoder_output , z_size , name = 'encoder/mu' , kernel_initializer = tf . random_normal_initializer ( stddev = 0.001 ) ) sigma = tf . layers . dense ( encoder_output , z_size , activation = tf . nn . softplus , name = 'encoder/sigma' , kernel_initializer = tf . random_normal_initializer ( stddev = 0.001 ) ) return ds . MultivariateNormalDiag ( loc = mu , scale_diag = sigma )