(self, n, max_length=None, z=None, c_input=None, **kwargs)
return self.decoder.sample(n, max_length, z, c_input, **kwargs)
Sample with an optional conditional embedding `z`.
Sample with an optional conditional embedding `z`.
Sample with an optional conditional embedding z .
def sample(self, n, max_length=None, z=None, c_input=None, **kwargs):
    """Sample with an optional conditional embedding `z`."""
    if z is not None and int(z.shape[0]) != n:
      raise ValueError(
          '`z` must have a first dimension that equals `n` when given. '
          'Got: %d vs %d' % (z.shape[0], n))

    if self.hparams.z_size and z is None:
      tf.logging.warning(
          'Sampling from conditional model without `z`. Using random `z`.')
      normal_shape = [n, self.hparams.z_size]
      normal_dist = tfp.distributions.Normal(
          loc=tf.zeros(normal_shape), scale=tf.ones(normal_shape))
      z = normal_dist.sample()

    return self.decoder.sample(n, max_length, z, c_input, **kwargs)
def sample ( self , n , max_length = None , z = None , c_input = None , * * kwargs ) : if z is not None and int ( z . shape [ 0 ] ) != n : raise ValueError ( '`z` must have a first dimension that equals `n` when given. ' 'Got: %d vs %d' % ( z . shape [ 0 ] , n ) ) if self . hparams . z_size and z is None : tf . logging . warning ( 'Sampling from conditional model without `z`. Using random `z`.' ) normal_shape = [ n , self . hparams . z_size ] normal_dist = tfp . distributions . Normal ( loc = tf . zeros ( normal_shape ) , scale = tf . ones ( normal_shape ) ) z = normal_dist . sample ( ) return self . decoder . sample ( n , max_length , z , c_input , * * kwargs )